From 4.3 we have a new template, singular.php. I tried to understand what is it, but I didn't get it. :)

The page.php for pages. The single.php for every post types. If we have single-[post-type].php we can use a specific template for the custom post type.. so why we need singular.php?


It's the nature of the WordPress template hierarchy - point being, if you don't have a page.php, it will use singular.php, same if you don't have single.php, it will fallback to a template lower in the hierarchy.

Ideal for themes that have the same layout for posts/pages, instead of having duplicate code in each respective template.

| improve this answer | |

singular.php is basically an extra fallback for all post types, regardless if built-in or custom. It comes in straight after single.php and page.php, so you can omit the latter two templates and just have a singular.php template which will be used by all post types in single view.

How useful it will be and the necessity of it will, just as with any other template, depend on the user/site/requirements. The template hierarchy is built such that, regardless of any page being viewed, you will always just need index.php to display any page. So in short, you can have a fully functional theme with only index.php and style.css in the theme folder.

The templates available in the template hierarchy are just there for convenience, and that goes for singular.php as well. You can use any template in context if you need to, but you don't have to use it if you don't need it.

| improve this answer | |

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

1.single-{post-type}.php – First, WordPress looks for a template for the specific post type. For example, post type is product, WordPress would look for single-product.php.

2.single.php – WordPress then falls back to single.php.

3.singular.php – Then it falls back to singular.php.

4.index.php – Finally, as mentioned above, WordPress ultimately falls back to index.php.


The 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:

1.custom template file – The page template assigned to the page. See get_page_templates().

2.page-{slug}.php – If the page slug is recent-news, WordPress will look to use page-recent-news.php.

3.page-{id}.php – If the page ID is 6, WordPress will look to use page-6.php.





| improve this answer | |
  • singular.php is also a fallback for page.php – Pieter Goosen Sep 4 '15 at 15:48
  • yes it is a fallback for page.php as well – matthew Sep 4 '15 at 16:10
  • added the page.php – matthew Sep 4 '15 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.