Questions tagged [template-hierarchy]

"Template hierarchy" describes process by which WordPress determines which theme files to use when displaying a query. Index.php is the fallback for all queries, and, theoretically, the only theme file required other than style.css.

Filter by
Sorted by
Tagged with
39
votes
6answers
76k views

Template Hierarchy: confused with index.php, front-page.php, home.php

I'm really confused with index.php, home.php and front-page.php. In many cases even though I had an index.php, I overwrite it with front-page.php. But recently, I became aware about home.php. What's ...
28
votes
1answer
29k views

How to create custom 401, 403 and 500 error pages?

When a 404 error is encountered, a 404.php template file can be used to render a custom error message. This is documented in the Template Hierarchy article. My aim is to create custom error pages ...
20
votes
6answers
13k views

single-{$post_type}-{slug}.php for custom post types

My favorite part of the Wordpress template hierarchy is the ability to quickly create template files for pages by slug, without having to edit the page in Wordpress to select a template. We can ...
13
votes
3answers
7k views

What is singular.php?

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 ...
11
votes
2answers
6k views

Custom Post Type Plugin: Where Do I Put The Template?

I'm writing a custom post type plugin. Part of it I'm outputting to the template via shortcodes. But other parts need a custom post template, and I figured out how to use the template hierarchy for ...
9
votes
1answer
496 views

Custom taxonomy query broken after upgrade to 4.4

I just upgraded from 4.2 to 4.4 and now my taxonomy query returns empty. It has been working fine prior to the upgrade. I have registered a custom taxonomy named 'title', which is used by my custom ...
8
votes
1answer
1k views

CPT Template Not Showing - Getting 404

I'm developing a Custom Post Type plugin, which works fine in dev. Now that I've moved it to production, I'm getting a 404 when I try to display the template for the CPT. So, two questions: 1- Is ...
6
votes
3answers
492 views

Create “File-less” Page Template in Functions.php

(By "Page Template," I mean a theme file with the "Template Name" header that can be selected in the "Template" dropdown field on the page admin.) In multiple instances, I've built page templates ...
5
votes
2answers
4k views

Template for specific post of custom post type

I have the CPT "event". I have created single-event.php. I want one particular event to use a different template than single-event. I read elsewhere that this could be done by creating a single-...
5
votes
1answer
134 views

Is it possible to manipulate the list of page templates?

After answering this question I wondered if it is possible to manipulate the dropdown list of possible page templates that's available when you edit a page. WordPress derives this list from the ...
5
votes
1answer
1k views

How to use a specific category archive index as the site front page?

I investigated Wordpress hierarchy and have created a php file called category-image-gallery.php the link to this is http://www.phoneographer.org/category/image-gallery/ having uploaded it and added ...
5
votes
2answers
837 views

Overide get_template_part( 'partials/post', 'sidebar' ); with a plugin

I am working on a site for a client who has a theme built for them by a different developer. They have asked me to make some changes to the site, and I'd like to put all of my changes into a plugin as ...
5
votes
1answer
742 views

Loading partial templates with AJAX/PJAX

I am trying to load content using PJAX (basically AJAX with history). So far I have managed to catch PJAX requests and load the correct content. My problem is finding the correct template to use for ...
4
votes
3answers
18k views

Is there a default template file for child pages / subpages?

This seems like a very simple question. I'm looking for something like sub-page.php or page-child.php where I can do some different things on the child pages of my theme. They are different enough ...
4
votes
2answers
35k views

How to override WooCommerce template files?

I was trying to customize the shop page (adding widget area to the page). Is there any way or plugin to help me do so? I created a page-shop.php however no changes were seen.
4
votes
2answers
1k views

Taxonomy Templates… by hierarchical level?

Is there a way to use different templates for different levels within a hierarchical taxonomy, specified by filename. I know about taxonomy-taxonomyname.php and taxonomy-taxonomyname-term.php ...
4
votes
3answers
8k views

How to make child categories recognize parent's template displays

I'm using the Default Post Type post for various purposes. To sort them I'm using different categories. And I'm designing different category layout using the slug preference, like: category-book.php, ...
4
votes
2answers
2k views

Display Editable Text Above CPT Archive Listings

I have two custom post types (Authors and Partners). I display their archive page's in the main navigation and use archive-authors.php and archive-partners.php to make a couple small tweaks to the ...
3
votes
2answers
5k views

Different templates for parent and children categories/taxonomies

I would like to know what is the best way to create a different template for parent and children categories and/or taxonomies. Example: I have a taxonomy called region, which I want to divide in ...
3
votes
1answer
35 views

Archive page showing nothing - issue with WordPress Hierarchy?

I'm building a theme and I've found it all pretty simple and straightforward. However, I can't figure out why I have a totally blank page for my archive WordPress blog posts? I understand the ...
3
votes
1answer
180 views

How to use same theme template for multiple taxonomy terms?

How would I use the same template file for, say three specific taxonomy terms but not the remaining three? I know taxonomy-taxname.php is the file for all terms I know taxonomy-taxname-termname.php ...
3
votes
1answer
3k views

How can I set up a category “overview” page?

I know I can use the Template Hierarchy to set up custom theme pages for terms inside a category, like these: mysite.com/category/tech/ // category-tech.php mysite.com/category/blog/ ...
3
votes
1answer
312 views

Is it possible to have an index page for taxonomy term for each custom post type it is assigned to?

I currently have a setup where I have a custom taxonomy that is link to the Wordpress post post type and another custom post type. Since the custom taxonomy is assigned to the two post types ...
3
votes
1answer
1k views

Overriding default template if page slug and post type are same

I have created a post type named 'faq', and a page 'faq' for displaying the posts under faq. Also I have created a page template name faq and selected the faq page's template to this. Now the ...
2
votes
3answers
7k views

Multiple Single Post templates

I have a custom post type called funerals and a page the lists all the posts part of that custom post type. To display a single page I create a file called single-funerals.php and that all works well....
2
votes
2answers
3k views

WooCommerce Template overriding not working with woocommerce.php

I am creating a custom theme with my own HTML. I am trying to override woocommerce template. I have created a template named with woocommerce.php but it still shows template with default structure. I ...
2
votes
1answer
2k views

is_archive() content being shown instead of is_category()

My Issue: If I browse to http://mysite/category/mycategory, the if (is_category()) content isn't displayed, the if(is_archive()) is shown instead. My code: archive.php: <?php include('includes/...
2
votes
1answer
287 views

Load front-page.php from subfolder

My front-page.php works fine in the WordPress root folder. But I would like to put it in the page-templates subfolder. How do I make it load from there?
2
votes
2answers
130 views

Categories Template Assistance

I have found a tutorial online for creating a custom categories template for my archived posts within a particular category. This however is targetting a specific category ID (see below), is there ...
2
votes
2answers
64 views

Load template file without a post type

Is there a way of loading a template file without having a post? I'm loading set of data via an API. Set up my index page but having a brain freeze with single template files as these posts are not in ...
2
votes
1answer
87 views

How to apply a custom template for posts by default?

I have created a custom template. Now how do I apply my template instead of single.php for posts by default? I want to do this so that theme upgrade doesn't replace by custom template.
2
votes
4answers
120 views

WordPress Template Hierarchy

Hi I have question about file names. If I have custom post type, and for template I can create for example single-portfolio.php and get content of portfolio posts into this file, but i need to get ...
2
votes
1answer
3k views

Displaying all Video Post Formats to Page

I am creating a video-archive page for all the posts_format with video. Currently, I have: <?php $format = has_post_format('video', $post_id); ?> <?php if($layout != "fullwidth") { ...
2
votes
5answers
9k views

How can a Theme Contain no Header File or Footer File?

Some themes that I have seen such as the (famous) thesis or even a few other not so famous themes have just an index.php (which has nothing in it), functions.php (call's their framework) and a style....
2
votes
1answer
101 views

Any tag pagination page (except the 1st page) loads index.php template instead of tag.php

Created my first custom theme from scratch and I'm trying to do a listing of all posts with the same tag. In tag.php I display all posts with that specific tag via a WP_Query and I'm trying to ...
2
votes
1answer
612 views

Rewrite Custom Post Type URL slug

Hello StackExchange WP_development :) I am in a bit of a pickle with this one and i certainly hope you can consult me further. Im helping out with a WordPress site that is build as a "singlesite". ...
2
votes
2answers
648 views

Where to put my global functions?

I currently have a global function in my functions.php file ein_error_log($message) { //push out $message to file... } But I want to start using it in my MU-Plugin directory and it doesn't ...
2
votes
0answers
27 views

Unable to include a template

On the home.php, which is in the same folder where style.css is kept I am try to call a template: <?php get_template_part( 'template-parts/content', 'home-default' ); ?> template-parts is a ...
2
votes
1answer
478 views

Custom post type and taxonomy permalinks - Structure

Been trying to get a nest of custom post type and taxonomy working (even took a look here) but couldn't get it working 100%. Here is the thing, I created a custom post type texturas_temp and a custom ...
1
vote
5answers
7k views

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 ...
1
vote
2answers
8k views

Different template for subcategories

I would like to have a different template for categories and subcategories The categories template is set in categories.php is it somehow possible to load the subcategories template from subcategories....
1
vote
1answer
121 views

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 ...
1
vote
2answers
2k views

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 ...
1
vote
1answer
228 views

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 ...
1
vote
2answers
3k views

Custom Post Type with Nested Taxonomy and Template Files

I have a custom Post Type of "Portfolio" with a rewrite slug of portfolio. So the URL on the frontend is: domain.com/portfolio. I have a custom Taxonomy of "Categories" with a rewrite slug of ...
1
vote
2answers
940 views

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 ...
1
vote
1answer
620 views

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 ...
1
vote
2answers
1k views

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 ("...
1
vote
1answer
103 views

Load custom template for specific GET parameter

How is it possible to load a different template file when a specific GET parameter is set? I want to create an account details page. So when the account parameter is set there should be loaded for ...
1
vote
2answers
64 views

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. ...

1
2 3 4 5