WP theme development 06: overall structure of wordpress theme template, wp theme development tutorial

1 year ago (2023-12-05) Chief Editor
7 minutes
three hundred and seven
one

After the static template of the wordpress theme is written, we can officially enter into the development of the dynamic template of the wordpress theme. The so-called dynamic template is to call the data in the wordpress database through the PHP function and PHP syntax provided by the wordpress program and display it in the front static template of the wordpress website. Any movement of the website can be displayed in the front through the dynamic template. Before developing the dynamic template of the wordpress theme, we need to understand the overall structure of the wordpress dynamic template.

1: Required option for wordpress dynamic template.

The so-called mandatory option is indispensable for WordPress dynamic template. You can follow my action and demonstrate it together.

1. Create a theme directory.

We enter the/wp content/themes/directory under the wordpress program, and create a trans directory under this directory (you can also use other names), which is equivalent to creating a new theme template for the current wordpress website. The template name is trans.

2. Create a template CSS style file.

After adding the template directory, we can see the relevant prompt in the theme interface under the appearance of WordPress background: "Corrupt theme, the following themes have been installed, but are incomplete. The style sheet is missing." (see the following figure).

Create a CSS style file sytle.css in the trans directory. The file name must be style, otherwise it is invalid. This file is necessary for the WordPress dynamic template. If it is missing, an error will be reported immediately.

3. Create a homepage template.

After adding the CSS stylesheet file, let's look at the background theme interface again. At this time, we found another prompt: "Damaged theme. Template missing. Independent theme needs an index.php template file", as shown below:

In other words, the WordPress dynamic template must have a homepage template, index.php. If it is missing, such an error will be reported. Therefore, we will create an index. php file in the trans directory.

4. Add background thumbnail of trans theme dynamic template.

After adding the index.php homepage template, I return to the background theme interface of the wordpress website to check. At this time, there is no error again. This means that the style.css stylesheet file and the index.php homepage template file are necessary for the wordpress dynamic template. If any one is missing, an error will be reported.

However, we also found the following problem: other wordpress theme templates have thumbnails, and you can see the general effect. The trans theme template we created has no thumbnails, and is blank, as shown below:

At this time, we must put a thumbnail into the trans theme directory. The name of the thumbnail must be screenshot, and the suffix can be png, jpg, gif. After adding thumbnails, they will be displayed in the background, as shown below:

These are the necessary options for the WordPress theme dynamic template: style.css stylesheet file, index.php homepage template file, and screenshot theme thumbnail. After that, we can click the "Enable" button to let the current WordPress website use the trans theme template. Of course, if it is enabled at this time, the foreground page will not display anything, and it is a blank page, because we have not put any content and called any data in index.php.

2: Optional options for wordpress dynamic templates.

After completing the required options of wordpress dynamic template, our trans theme template can be used normally. For some WordPress websites with low demand, the entire website may only need one page, such as the Taobao guest theme template, which was particularly popular in the past few years. These Taobaoke websites have no article data, and they only have a simple homepage template, which shows the product links and pictures they got from Taobao Alliance. As long as users click on these products and go to Taobao to consume, WordPress webmasters can earn money.

However, for those of us who are serious website owners, our WordPress website can not only have one page, our website will have many pages. Therefore, when developing WordPress theme templates, we need to create some other template files. This is an optional option for WordPress dynamic templates.

The normal WordPress theme template generally includes the following template files:

Functions. php=>Theme function file archive. php=>List page template page. php=>Single page template 404. php=>404 Error page template header. php=>Header template footer. php=>Bottom template sidebar. php=>Sidebar template search. php=>Search page template searchform. php=>Search form template comments. php=>Comment template

It may also contain the following directories:

Images=>Picture folder js=>JS folder css=>Other CSS style folders include=>Other PHP function folders

Of course, the above optional template files and directories are not fixed. We can choose them according to the specific situation of our website. We can open the official theme of WordPress. Let's open the theme directory of tweetytwenty to see how many optional templates have not been created, as shown in the following figure:

When we open the directory of another official theme template, tweenysixteen, we can see that it basically contains the template files of the optional options we introduced above. As shown below:

Now let's take a look at the ssmay theme developed without stopping. It contains not only the theme template files of mandatory and optional items, but also some other template files, as shown below:

It can be seen that when we develop WordPress dynamic templates, there is no fixed mode. The mode of creating templates is not dead. We should create our own dynamic template files according to the actual situation of our WordPress website and our specific needs. That is to say, in addition to the mandatory items of the dynamic template introduced above, we can flexibly use the others, regardless of the format.

This article is written by: Chief Editor Published on Software Development of Little Turkey , please indicate the source for reprinting: //hongchengtech.cn/blog/1841.html
Kuke_WP editor
author

Related recommendations

1 year ago (2024-02-20)

What technologies have been applied and developed in the field of new media, and the application of new technologies in media

In the field of new media, many technologies have been applied and developed. These include: cloud computing: cloud computing technology enables new media companies to develop and deploy applications more quickly, and can dynamically adjust resources according to needs. Big data: New media companies can use big data technology to analyze massive user data, understand user preferences, behavior habits and other information
nine hundred and seventy-one
one
1 year ago (2024-02-20)

WMS warehouse management system, promoting the transformation of warehousing from extensive to fine management, WMS warehouse management

Warehousing is extremely important for the manufacturing industry and is an important guarantee for the survival and development of manufacturing enterprises. However, with the expansion of manufacturing enterprises' business, the traditional warehouse management has been unable to respond to business changes quickly. The extensive management mode not only makes the warehouse operation not smooth, but also increases the storage cost. Therefore, it is necessary for manufacturing enterprises to deploy a WMS warehouse management system
eight hundred and forty-eight
one
1 year ago (2024-02-20)

How to select MES system? Main contents of MES production management

Original title: How to select MES system? The main content of MES production management Production and manufacturing activities are the core activities of manufacturing enterprises. As the entity unit of manufacturing activities, planning objectives and the realization of enterprise value, workshop management is the focus of enterprise management. With the rapid development of manufacturing industry, MES is the focus and current hot spot of manufacturing enterprise information automation system
nine hundred and sixty-four
zero
1 year ago (2024-02-20)

The WeChat management system can manage the information content of WeChat more effectively. Let's manage the data of WeChat here

Original title: WeChat management system manages the information content of WeChat more effectively. Many enterprises will assign work to WeChat, because no one wants their personal WeChat to mix work and other related knowledge, but someone will always use the company's loopholes to do something harmful to the company's interests. Don't think such things are rare. I learned about a media financing company in Shenzhen. They have 3
seven hundred and seventy-seven
zero
1 year ago (2024-02-19)

Student electronic file management system, three-dimensional communication space of "home", "school" and "community", and school electronic files

In the era of big data, in the process of recording the growth of students, the school reexamines the management of student files, moves with the times, and promotes the reform of student growth files with new thinking. "Electronic files of primary and secondary school students' growth records" have been gradually introduced into educational management, and show vigorous vitality. Student file management system is an indispensable part of the school, its content for the school
five hundred and seventy-one
zero
1 year ago (2024-02-19)

Ruizhe Information: Select Sitecore? Or... just six steps to choose a content management system, Ruizhe Information Technology Service Co., Ltd

The content management system (CMS) is an important part of the success of website construction. At present, the content management system on the network is relatively complex. It is not easy to find a good content management system that is very suitable for the current digital marketing environment. Before we compare the functionality, operation, scalability, security and other specific performance of the major CMS systems, we need to achieve
three hundred and forty-three
zero

comment

0 people have participated in the review

Scan code to add WeChat

contact us

WeChat: Kuzhuti
Online consultation: