Wordpress Theme Development - Hierarchy

Introduction

Wordpress Hierarchy is very important for theme development in wordpress. Hierarchy determines what custom template to display during specific situations. For example we can have a custom category or a custom archive page if we want to.

Here’s a hierarchy chart that shows the ranking of the hierachy wordpress template. However, to be honest I only use couple of the custom templates.

WP Hierarchy

Custom page

For custom page you want to create a page-$slug.php (for example page-about.php). Then in your pages in wordpress we can select which page template we want to use for this page. I use this the most in my custom theme development.

Some of the other ones in the hierachy chart is pretty obvious like category.php is a custom template for category page, archive.php for archive page, single.php for single post page.

If you really want a specific template css for a specific category page. Then you would need to look up the chart and look at the options for category. So the ranking is category.php > $category-$id.php > category-$slug.php.

Reference