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.
241
questions
47
votes
6
answers
89k
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 ...
30
votes
1
answer
38k
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 ...
22
votes
6
answers
16k
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 ...
15
votes
3
answers
12k
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
2
answers
7k
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 ...
10
votes
3
answers
60k
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.
9
votes
1
answer
528
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
1
answer
2k
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
4
answers
24k
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 ...
6
votes
3
answers
1k
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 ...
6
votes
2
answers
1k
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
2
answers
13k
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....
5
votes
3
answers
9k
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, ...
5
votes
3
answers
12k
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....
5
votes
2
answers
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
1
answer
11k
views
What is the point of using archive.php instead of index.php?
Dumb Questions Ahead:
If index.php and archive.php are practically the same thing, what's the point of having archive.php?
When should I ever want to use archive.php over index.php?
If I use front-...
5
votes
1
answer
178
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
1
answer
2k
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
1
answer
1k
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
2
answers
2k
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
2
answers
3k
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
2
answers
6k
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
1
answer
545
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
1
answer
635
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
1
answer
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
1
answer
1k
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
1
answer
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
2
answers
10k
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
5
answers
9k
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 ...
2
votes
2
answers
211
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.
...
2
votes
2
answers
1k
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 ...
2
votes
1
answer
3k
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
1
answer
1k
views
Templating of a specific post ID
I'd like to know it's possible to do something like this
single-post-45.php
I needn the post(45) only to have a custom template.
I know we can achieve this with page, like this
page-45.php
or by a ...
2
votes
1
answer
2k
views
Rewrite URL for only archive page (custom post type)
There is a few Q/A about custom post URL rewrite but I haven't found any simple answer to what I'm trying to achieve.
My CTP is "event" and I have the current page structure that I want to preserve:
...
2
votes
1
answer
936
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 ...
2
votes
1
answer
431
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
2
answers
6k
views
Custom Taxonomy term archive template
Is it possible to have separate archive templates for custom taxonomies?
Like this:
Tax(categories)
-Players(category)
-Managers(category)
2
votes
2
answers
136
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
2
answers
79
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
1
answer
2k
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
4
answers
160
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
1
answer
304
views
For custom templates, is it better to use `template_include` or `type_template`?
I saw a lot of questions about including custom views in Wordpress (I mean custom templates).
There were many answers. Some people recommend using template_include and others recommend using ...
2
votes
3
answers
4k
views
Which php file lists all the post of a category
In my primary menu, I have added a category "News & Events" and when I click this page, I get all the posts of this category. Which php file I have to edit, in order to change some things that I ...
2
votes
1
answer
4k
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
5
answers
12k
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
2
answers
374
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
1
answer
715
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
2
answers
5k
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
0
answers
29
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
1
answer
494
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 ...