Wordpress topic creation tutorial (2): topic File structure

Source: Internet
Author: User
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:

  1. Home. php

  2. Index. php (this is omnipotent)

Article page:

  1. Single-{post_type}. php-if the article type is videos (video), WordPress will look for the single-videos.php (WordPress 3.0 and later)

  2. Single. php

  3. Index. php

Page:

  1. 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.

  2. Page-{slug}. php-if the page name is news, WordPress will look for the page-news.php (WordPress 2.9 and later support)

  3. Page-{id}. php-if the page ID is 6, WordPress will look up the page-6.php

  4. Page. php

  5. Index. php

Classification template:

  1. Category-{slug}. php-if the category is abbreviated to news, WordPress looks for the category-news.php (WordPress 2.9 and later support)

  2. 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

  3. 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

  4. Category-{id}. php-if category ID is 6, WordPress looks for the category-6.php

  5. Category. php

  6. Archive. php

  7. Index. php

Tag

  1. Tag-{slug}. php-if the tag is abbreviated to sometag, WordPress looks for the tag-sometag.php

  2. Tag-{id}. php-if the tag ID is 6, WordPress looks for the tag-6.php (supported by WordPress 2.9 and later)

  3. Tag. php

  4. Archive. php

  5. Index. php

Author:

  1. Author-{nicename}. php-if the author's nickname is rami, WordPress will look for the author-rami.php (WordPress 3.0 and later support)

  2. Author-{id}. php-if the author ID is 6, WordPress will look for the author-6.php (WordPress 3.0 and later support)

  3. Author. php

  4. Archive. php

  5. Index. php

Date page:

  1. Date. php

  2. Archive. php

  3. Index. php

Search results:

  1. Search. php

  2. Index. php

404 (not found) page

  1. 404. php

  2. Index. php

Attachment page:

  1. MIME_type.php-it can be any MIME type (image. php, video. php, audio. php, application. php, or others ).

  2. Attachment. php

  3. Single. php

  4. Index. php

Function

  1. Functions. php

Comment Template

  1. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.