wordpress template hierarchy

Do you want to learn about wordpress template hierarchy structure? The core WordPress software, themes, plugins, and user uploads are all stored on your website. In this beginner’s guide, we will explain the WordPress template structure.

1. Home Page display According WordPress structure

By default, wordpress structrure sets your site’s home page to display your latest blog posts. This page is called the blog posts index. You can also set your blog posts to display on a separate static page. The template file home.php is used to render the blog posts index, whether it is being used as the front page or on separate static page. If home.php does not exist, WordPress will use index.php.
1.home.php
2.index.php
Note: If front-page.php exists, it will override the home.php template.

2. Front Page display

The front-page.php template file is used to render your site’s front page, whether the front page displays the blog posts index (mentioned above) or a static page. The front page template takes precedence over the blog posts index (home.php) template. If the front-page.php file does not exist, WordPress will either use the home.php or page.php files depending on the setup in Settings → Reading. If neither of those files exist, it will use the index.php file.

1.front-page.php – Used for both “your latest posts” or “a static page” as set in the front page displays section of Settings → Reading.
2.home.php – If WordPress cannot find front-page.php and “your latest posts” is set in the front page displays section, it will look for home.php. Additionally, WordPress will look for this file when the posts page is set in the front page displays section.
3.page.php – When “front page” is set in the front page displays section.
4.index.php – When “your latest posts” is set in the front page displays section but home.php does not exist or when front page is set but page.php does not exist. click here to know what is wordpress

3. Single Post

The single post template file is used to render a single post. WordPress uses the following path:

1.single-{post-type}-{slug}.php – (Since 4.4) First, WordPress looks for a template for the specific post. For example, if post type is product and the post slug is dmc-12, WordPress would look for single-product-dmc-12.php.
2.single-{post-type}.php – If the post type is product, WordPress would look for single-product.php.
3.single.php – WordPress then falls back to single.php.
4.singular.php – Then it falls back to singular.php.
5.index.php – WordPress ultimately falls back to index.php.
click here to know what is wordpress

4. Single Page

The wordpress template file used to render a static page (page post-type). Note that unlike other post-types, page is special to WordPress and uses the following patch:

custom template file – The page template assigned to the page. See get_page_templates().
1.page-{slug}.php – If the page slug is recent-news, WordPress will look to use page-recent-news.php.
2.page-{id}.php – If the page ID is 6, WordPress will look to use page-6.php.
3.page.php
4.singular.php
5.index.php

5. Category

Rendering wordpress template category archive index pages uses the following path in WordPress:

1.category-{slug}.php – If the category’s slug is news, WordPress will look for category-news.php.
2.category-{id}.php – If the category’s ID is 6, WordPress will look for category-6.php.
3.category.php
4.archive.php
5.index.php

I, Dayanand Saini,the founder and chief editor of www.webtechsource.com,have been working as a software engineer from last 4+ years. It's my hobby to learn new things and implement on live environment.

Leave a Reply

Your email address will not be published. Required fields are marked *

3 + 7 =

%d bloggers like this: