Articles of template hierarchy

index.php template is used instead of blog page

I am trying to set WordPress so that home page is static, and the blog page is a separate page. So, I created two page templates in my theme., lets call them home_template and blog_template. Then, I created two WordPress pages (from Pages -> Add New). The first page is called Home, and is using […]

Change Page Template Based on Category

How can I display a post with a certain category in the page template instead of default category template. For an example, I want to show all posts under category “Scott” with the page template (“page.php”).

where is the code that executes the template hierarchy?

I can see a picture of the template hierarchy here, but where is the actual wordpress code which decides that it’s a “category page” or an “archives page” or a “search page”?

Taxonomy landing pages

I like to create a landing page for my custom taxonomies. Right now ive created three custom taxonomies /country/[terms] /person/[terms] /interrests/[terms] i like to create a listing page for each of the taxonomy, this listing page should list all the [terms] they contain. And link to the normal (taxonomy-[term].php /taxonomy/[term]) url. What is a proper […]

Trying to manage templates on a blog with lots of custom taxonomies

In my most recent project, I’m dealing with a website that included dozens of custom taxonomies, couple of post types, content, etc. and required different templates for different authors or tags. Right now, my template folder has about 70 php files for templates, which is really confusing. I noticed that some themes such as twentyseven […]

Which template name to use for taxonomies but not their terms?

I can’t figure out which template name to use to modify custom taxonomy archive page, but not the one for terms in that taxonomy. My goal is to show terms list in custom taxonomy archive and in custom taxonomy terms – custom post types.. {taxonomy}-{term}.php is used to display custom taxonomy terms ( so there […]

What should I put on my index.php?

I had covered basically all the pages listed in the Template Hierarchy: 404_template archive_template author_template category_template tag_template taxonomy_template home_template front_page_template page_template search_template single_template attachment_template I’m using the front-page.php for my static front page and home.php for by blog index. So, with all that covered, what should I put into my index.php? Or can I leave […]

Template Hierarchy for get_header()

I’m considering having different headers depending on the area of the site. So thought it might be possible to tap into the template hierarchy (or at the very least, re-use some of the code) and filter the output. Is this something that anyone has tried? Or could anyone point me in the direction of the […]

Understanding the WordPress template hierarchy

I watched a lot of courses about WordPress Development on Udemy. Also I’ve almost finished my “WordPress Development” track on Teamtreehouse, but I can’t understand one simple thing, because one course a little bit contradicts another. My question is about page.php, content.php and single.php. What is the best practice to use these files? For example, […]

WordPress not respecting template hierarchy (fetches index.php instead of single.php or page.php)

I’ve encountered a strange error while developing a custom theme. After finishing editing the template for a custom post type single view, I passed onto working at the template files for pages and I ealized that WordPress was actually pointing to index.php template file rather than page.php in my theme for generating the page appearance. […]