Before creating a WordPress topic, you must first understand which files the WordPress topic consists of and how the WordPress program connects to the topic file. Generally, a topic must contain at least two files: index.php and style.css. In short, there may be Files
Before creating a WordPress topic, you must first understand which files the WordPress topic consists of and how the WordPress program connects to the topic file. Generally, a topic must contain at least two files: index.php and style.css.
Specifically, the following files may exist:
Home page:
Home. php
Index. php (this is omnipotent)
Article page:
Single-{post_type}. php-if the article type is videos (video), WordPress will look for the single-videos.php (WordPress 3.0 and later)
Single. php
Index. php
Page:
Xxx. php (file name casually), custom page template-when creating a page in the WordPress background, you can select a custom template on the right-side bar.
Page-{slug}. php-if the page name is news, WordPress will look for the page-news.php (WordPress 2.9 and later support)
Page-{id}. php-if the page ID is 6, WordPress will look up the page-6.php
Page. php
Index. php
Classification template:
Category-{slug}. php-if the category is abbreviated to news, WordPress looks for the category-news.php (WordPress 2.9 and later support)
Archive-{post_type }. php-if your topic has a custom article type, such as registering an article type named book according to the official website tutorial, then its archive page template is the category-book.php, if this file is not available, it will not be replaced by other files and will go straight to 404
Taxonomy-{taxonomy_slug }. php-this is the classification page of the custom classification. for example, you have registered the document type of a book above, and then you have registered an author classification. its alias is authors, so that the document can be classified by author. Then the author's category page template file is taxonomy-authors.php
Category-{id}. php-if category ID is 6, WordPress looks for the category-6.php
Category. php
Archive. php
Index. php
Tag
Tag-{slug}. php-if the tag is abbreviated to sometag, WordPress looks for the tag-sometag.php
Tag-{id}. php-if the tag ID is 6, WordPress looks for the tag-6.php (supported by WordPress 2.9 and later)
Tag. php
Archive. php
Index. php
Author:
Author-{nicename}. php-if the author's nickname is rami, WordPress will look for the author-rami.php (WordPress 3.0 and later support)
Author-{id}. php-if the author ID is 6, WordPress will look for the author-6.php (WordPress 3.0 and later support)
Author. php
Archive. php
Index. php
Date page:
Date. php
Archive. php
Index. php
Search results:
Search. php
Index. php
404 (not found) page
404. php
Index. php
Attachment page:
MIME_type.php-it can be any MIME type (image. php, video. php, audio. php, application. php, or others ).
Attachment. php
Single. php
Index. php
Function
Functions. php
Comment Template
Comments. php
About the above file hierarchy
In addition to the user-defined document type, the above and the user-defined classification method require a fixed Template to display the corresponding content. Others, if the corresponding file is missing, can be replaced by other files. Take the home page as an example. There are two files: home. php and index. php and WordPress will search for these two files from your topic folder in sequence. if you find home. php, use home. php serves as a blog homepage template, even if your topic folder contains index. php; if the home. if php is not found, index is used. php is used as the homepage template. php and index. php cannot be found, and your theme will not be identified by WordPress, which is equivalent to waste.
Not all of the above files need to be prepared, and any template is required. for complex theme, there are usually many php functions, in order to have a clear hierarchy, the author usually splits the code into other PHP files, which can be found in functions. php uses functions such as include_once to include files.