This is a useful tutorial for WordPress administrators and beginners in theme development. This talks about WordPress template hierarchy and its application. This topic can be so broad but let’s only talk about its most important implementation that you can use within your own website.
By design, most WordPress themes contain template files for serving content from different sections in your WordPress site. These sections could be your blog post, categories, pages, homepage, tags, author pages, etc.
These template files are found in your WordPress theme directory: /wp-content/themes/theme_name/.
The following are the most important template files for generating content:
- single.php – template file used by your posts.
- page.php – used in generating pages (not blog post) in your WordPress site.
- archive.php – archived pages. Categories and tags are also considered as archives.
- category.php – template specific for categories.
- tag.php – specific template for WordPress tags.
- index.php or home.php – template for generating front page content in your blog.
- sidebar.php, footer.php, etc. still belongs to the theme files but they are only part of the more important templates mentioned previously.
Most WordPress theme developers have the freedom to decide what templates they are going to use in representing different content sections of your site. For example, it is common to see WordPress themes that only uses archive.php for generating the following WordPress content:
- Categories
- Tags
So in this type of theme, you cannot see the following template files in your theme directory because they are not being used:
- category.php
- tag.php
Other example is where you realize home.php is the one being used to generate front page content instead of index.php. In some themes, there is no home.php but instead use index.php in serving home page content.
This tutorial contains :
The post WordPress Template Hierarchy appeared first on Tutorial Mini.
Related posts:
- The Anatomy of a WordPress Theme – Theme Location
- WordPress SEO Tutorial – Template Optimization
- The Anatomy of a WordPress Theme
via Tutorial Mini http://tutorialmini.com/wordpress-template-hierarchy/
No comments:
Post a Comment