ArticleDirectory
- Index. php-home
- Single. php-individual posts
- Page. php-individual pages
- Archive. php, category. php, tag. php-Archives
- Comments. php
- Functions. php
- Style.css
With powerful technologies, WordPress-based websites can be made into various forms. In addition to requiring WordPress theme developers to be proficient in HTML, PHP, JS, CSS, and other technologies, developers also need to master the WordPress topic framework.
Gevin today's combinationThe anatomy of a WordPress themeThis article analyzes the structure of the WordPress topic. The original author uses the text formatWebsite appearance, page composition, and background filesIn three aspects, the image shows you the WordPress architecture. The following gevin analyzes with you how WordPress is structured.
Website appearance
A WordPress topic consists of a series of template files, each of which controls a part of the topic. No matter which page of the blog, the framework of the topic remains unchanged. This is the static part of the topic, which consists of the header. PHP, sidebar. PHP and footer. PHP file control. We can modify these files to check the pages we browse and display different contents, such as displaying different navigation on the posts page and page. However, we usually keep static parts consistent throughout the website.
The appearance of the website consists of the following four parts:CodeControl:
- Header. php
Display blog headers and navigation, including HTML code
- The loop
The template file that displays the website theme content is called the loop (which will be detailed later ).
- Sidebar. php
This file controls the sidebar. You can add controls to topics on multiple sidebar in functions. php.
- Footer. php
The end of the website and the HTML closing tag.
Page Composition
The WordPress basic page has a homepage.(Index. php Control), Post page (Displays a complete blog, controlled by single. php), Independent page(Page. php Control), Archive(Archive. php)The following describes the code files that control these pages.
Index. php-home
The index file controls the appearance of the blog homepage. By default, the index file displays the latest blog through a loop, and a link to view the previous blog will be displayed at the bottom of the homepage.
Single. php-individual posts
This file is used to display the full text of a specific blog to be viewed by the reader.
Page. php-individual pages
This file controls the appearance of independent pages in the blog.
WordPress allows us to design different templates for different pages as follows:
1. Copy and rename page. php
2. Add the following code at the top of the file
<? PHP/* Template Name: yourpagenamehere */?>
Archive. php, category. php, tag. php-Archives
We can also customize the appearance of an archives file. If there is no archive. php file, the archive is exactly the same as the home page; however, we can create an archive. php file to reconstruct the archive page. If you create a category. php file, the archiving page overwrites the file to show only directories. If you create a tag. php file, the archiving page overwrites the file to show only labels.
The loop
Loop is probably the most powerful part of WordPress. It is the "loop query result ". In the loop body, we can output the title, Blog content, metadata, and comment of the selected Article in sequence. We can also use multiple loops in single page. For example, we can use one loop to display the full text of the blog, and the other loop to display the title and thumbnail of the relevant article.
The loop structure is as follows:
- Query post or page
- Start loop // start the loop
The_title
(Outputs the title of the post) // Title
The_excerpt
(Outputs the post excerpt) // Abstract
The_content
(Outputs the full post content) // content
The_category
(Outputs the post categories) // directory
The_author
(Outputs the post author) // prepared
The_date
(Outputs the post date) // Date
- Other tags (there is a variety of other tags you can use in the loop) // tag
Endwhile; // end the loop
- Exit the loop // exit the loop
WordPress background files
To make theme work, WordPress also needs some necessary background files. These files can be modified based on individual needs. They can greatly change the appearance of the website or provide more powerful functions.
Comments. php
This file controls the comment output. If you want to provide the comment function on your blog, put it in the loop. The comment. php file can be overwritten by plug-ins (such as disqus)
Functions. php
Functions. php allows us to run custom code on Wordpress to modify theme elements more freely.
Style.css
This is the main CSS file that controls the theme style. The top part of the file also contains the metadata of the topic, which is used to provide the topic name, author, and related links.
Graphic Analysis
The powerful WordPress profiling diagram of the original author is as follows:
In-depth analysis of WordPress Themes
Source: in-depth analysis of WordPress topic structure | Palan Image