The use of powerful technology, can be based on WordPress Web site into a variety of forms, which in addition to the requirements of WordPress theme developers proficient in HTML,PHP,JS,CSS and other technologies, but also need developers Master WordPress theme Framework.
Gevin today combined with the anatomy of a WordPress theme this article, and everyone together to analyze the structure of WordPress theme. The original author uses graphic form, respectively, from the site appearance, page composition and background files three aspects, the image to everyone shows the WordPress architecture, the following Gevin and everyone together to analyze how WordPress is structured.
Website appearance
The WordPress theme consists of a series of template files, each of which controls a part of the theme. Regardless of the page on the blog, the theme of the framework is always part of the same, this is the static part of the theme, it is controlled by header.php, sidebar.php and footer.php three files.
We can modify these files to detect the pages we browse and display different content, such as displaying different navigation on posts pages and page pages. However, in general, we keep the static part consistent throughout the site.
The appearance of the site is controlled by the following 4-part code:
header.php
Show blog header and navigation, also contain HTML code
The Loop
The template file that displays the content of the Web site theme is called the Loop, which is described in more detail later.
sidebar.php
The sidebar is controlled by this file. The multi-sided sidebar theme can be added to the functions.php control.
footer.php
The page footer of the Web site and the closing tab of the HTML.
Page composition
WordPress Basic Page has homepage (index.php control), post page (separate display of a full blog, controlled by single.php), independent pages (page.php control), archive (archive.php and other controls), the following are described in the respective control these pages The code file.
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 the previous blog is also provided at the bottom of the homepage.
Single.php–individual posts
This file is used to display the full text of a particular blog that readers want to view.
Page.php–individual pages
This file controls the appearance of separate pages in the blog.
WordPress allows us to design different templates for separate pages (pages) in the following ways:
1. Copy page.php and rename
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 the Archive (archives). If there is no archive.php file, the archive and homepage are identical; however, we can create a archive.php file to refactor the archive page. If you create a category.php file, the archive page is overwritten to show only the directory, and if you create a tag.php file, the archive page is overwritten to show only the labels.
The Loop
Loop is probably the most powerful part of WordPress. It is a "circular query result". In the loop body, we can output the title of the selected article, blog content, metadata, comments and so on in turn. We can also use multiple loops in a single page. For example, we can display the full text of a blog with one loop, and the other loop shows the title and thumbnail of the related article.
The loop structure is as follows:
- Query post or page
- Start loop //cycle starts
- The_title (outputs the title of the Post) //title
- THE_EXCERPT (outputs the post excerpt) //abstract
- The_content (outputs the full post content) //Contents
- The_category (outputs the post categories) //directory
- The_author (outputs the post author) //author
- The_date (outputs the post date) //Date
- Other tags (there are a variety of other tags you can use in the loop) //tags
- Endwhile; //End Loop
- Exit the loop //exit cycle
WordPress Background Files
In order to let the theme work, WordPress also needs some necessary background files. These files can be modified according to individual needs, which can greatly change the appearance of the website or provide more powerful functions.
comments.php
This file controls the output of the comment, and if you want to provide comment functionality on your blog, put it in the loop. comment.php files can be overwritten by plugins (e.g. Disqus)
functions.php
functions.php Let's run custom code on WordPress to make it more free to modify the theme elements.
Style.css
This is the main CSS file that controls the theme style. The top of the file also contains meta-information about the subject, which is used to provide the name of the subject, author and related links
Graphic analysis
Here is the original author of the powerful WordPress anatomy diagram:
Deep Anatomy wordpress Themes
Deep anatomy WordPress Theme Structure (GO)