2022 Developer Survey is open! Take survey.

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
0 votes
0 answers
47 views

Archive page of taxonomy returns a 404 error

I'm trying to create a template file for a custom taxonomy archive page but I keep getting a 404 error when trying to access that archive page. Basically something like: domain.com/quizzes/quiz-levels/...
user avatar
  • 1
0 votes
0 answers
68 views

Is it possible to set archive.php instead of index.php to display blog?

I have index.php and archive.php in my theme, but I'd like to using archive.php to display blog and category posts. Is it possible to override index.php by archive.php?
user avatar
  • 1
0 votes
0 answers
13 views

Prioritise Pages over Taxonomy Term Root Archive, but not Taxonomy Term Child Archives

I have a custom taxonomy (projects) linked to several different custom post types (events, stories, tutorials, news, podcast), as well as pages. [I KNOW, but that is how I need it to be] And have ...
user avatar
1 vote
0 answers
14 views

Wordpress Pagination changes my template

I have a problem using pagination for terms in my custom taxonomy, let's call it Case-Studies. If i go to /insights/page/2, posts will be displayed correctly, and I can navigate between pages. The ...
user avatar
0 votes
0 answers
38 views

What is the difference between the "Main Index Template"(index.php) and HomePage(front-page.php)

Just wonder what is the difference between the "Main Index Template" index.php and HomePage front-page.php. It seems that front-page.php is displayed when visiting https://www.example.com/, ...
user avatar
  • 41
0 votes
2 answers
16 views

understanding theme hierarchy

I know there is a high chance I understood this the wrong way and I have a linear thinking so please bear with me, I am just following the official documentation my understanding is if I create a file ...
user avatar
0 votes
1 answer
310 views

Wordpress custom pages in a folder

I cant find something similar I have a portal running WP and I want to create a mikro-site with 4 or more pages, under the same domain and let say I will name this : 'mikro' (I will use a different ...
user avatar
0 votes
1 answer
14 views

About template hierarchy

The hierarchy picture doesn't tell me exactly which one is dominant. /search/query/?category_name=general&post_type=custom /category/general/?s=query /tag/any/?s=query /custom_post/?s=query&...
user avatar
  • 3
1 vote
1 answer
131 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 ...
user avatar
  • 114
0 votes
0 answers
20 views

Wordpress hierarchy clarification, does post_type_archive take precedence over taxonomy-term archive?

Looking at the hierarchy diagram indeed the post_type archive is above the taxonomy however aren't they parallel and isn't taxonomy-term-archive more specific? the permalink: domain.com/cpt1/...
user avatar
  • 1
1 vote
1 answer
44 views

Include custom post type single template, but respect theme override of template if it exists

Through a plugin, I have created a custom post type named "my_custom". Also through the plugin, I am successfully including a template for the display of a "single" item of my ...
user avatar
0 votes
1 answer
75 views

Differentiation between index.php and page.php

I am currently developing a theme in wordpress for learning purposes. To set out to you my page hierarchy I have the following: index.php: fallback for all website pages home.php: blog page front-...
user avatar
  • 125
0 votes
1 answer
120 views

How to Override Page Template if URL matches query?

I have 4 Page Templates that my theme uses for all the pages - Default Template, Template One, Template Two and Template Three. When the relevant Page Template is selected, it loads an Advanced Custom ...
user avatar
  • 13
0 votes
1 answer
38 views

standard custom page template hierarchy for plugins

I know woo-commerce has it's own way of providing custom php templates in a child theme for its various views. I'm wondering if all plugins adhere to a standard way doing the same. For example, I'm ...
user avatar
  • 191
1 vote
1 answer
94 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 ...
user avatar
  • 421
1 vote
2 answers
844 views

How to load parent theme template parts in child theme

I was wondering how can I load parent theme template parts through child theme after customization. I have created three custom template for my theme and they are working fine. But now I want to load ...
user avatar
1 vote
1 answer
827 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: ...
user avatar
1 vote
1 answer
220 views

Hook to override title, image and content

I'm creating a custom post type with a plugin, and I want to show my cpt title/thumbnail/content... etc using hooks (assuming it's better than loading a custom template). But themes are showing title/...
user avatar
1 vote
0 answers
34 views

How to show single category archive

I have created the category.php template file for my wordpress custom theme. I put inside it the loop and the markup needed to disply my single category layout. I'm facing the issue that if the url is ...
user avatar
  • 321
1 vote
1 answer
1k views

Display Categories, Sub-categories, and Sub-sub-categories on separate pages

I am building a FAQ section in our mobile site which I would like to have the following hierarchy: Category > Sub-category > Sub-sub-category > Article I would like the category list and each sub-...
user avatar
3 votes
1 answer
292 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 ...
user avatar
  • 985
0 votes
1 answer
122 views

Restricting page templates by blog_id in multisite network

TL:DR; Is it possible to restrict page templates to a certain site within a multisite network? (Using something like get_current_blog_id for e.g) More details I’m building out several websites that ...
user avatar
  • 101
0 votes
0 answers
38 views

User role templates

I'm currently using the author.php template to display a frontend archive of users' posts from all roles. I've now created a new user role ("trainer") that needs to have a completely different ...
user avatar
0 votes
1 answer
184 views

Assign template to custom page type?

I have created a custom page type (using post state) for my project, so that I can select the page in the Reading settings like you do for page for posts and also for the home page. This is all ...
user avatar
  • 545
0 votes
0 answers
187 views

Overriding the template files using a plugin for all themes

I believe these are the common filters to use when overriding a template template_include single_template page_template archive_template The works but it seem that they are theme depended. I am ...
user avatar
2 votes
2 answers
4k 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 ...
user avatar
  • 71
0 votes
0 answers
24 views

Media item permalink goes to source file instead of attachment.php

My Media Library permalinks are bringing up the source items directly and seem to be ignoring my attachment.php file. This is happening for both attached and unattached files. I'm trying to use ...
user avatar
0 votes
2 answers
223 views

Single-page.php template file name not shown

I am developing a theme and I noticed that get_post_meta($post->ID, '_wp_page_template', true); returns 'static-page.php' (as expected) when queried on static pages but returns nothing (expected '...
user avatar
1 vote
3 answers
2k views

Wordpress Theme Development: How to redirect templates the right way?

I'm developing a theme for WordPress. I have a doubt about templates redirect. For example, I have a theme that have the front-page.php template and I don't use the index.php template. What I should ...
user avatar
2 votes
2 answers
70 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 ...
user avatar
0 votes
1 answer
77 views

BuddyPress : how can I call the template Wordpress would have chosen (template hierarchy)?

playing with BuddyPress here ! I made some new user profile pages, and when I display the content, I want to make a new posts query, and display the loop. Thing is, I want to display that loop using ...
user avatar
  • 452
0 votes
1 answer
311 views

Template files not working for archives and categories

I added category-news.php template file to the theme directory but it doesn't apply the template of the category but instead to the index.php file. category-slug.php is the highest level of the ...
user avatar
3 votes
1 answer
482 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 ...
user avatar
0 votes
2 answers
39 views

How can I make custom page templates work on child theme?

I have created a page template called concert.php under page-templates directory with the following content: <?php /* Template Name: Concert*/ add_body_classes('page_concert'); /* Custom ...
user avatar
0 votes
1 answer
743 views

Custom Archive Template for Multiple Categories

I want to create a custom archive template for two post categories. One of my categories is events, and the other one is courses (I have more). I already have a custom template for events (category-...
user avatar
  • 107
0 votes
1 answer
26 views

Custom Post Type Template Hierarchy - Single post template

I have registered a custom post type and I am trying to make posts of that type display in a specific template file but can't figure out what to name my template file in order for the posts to use it. ...
user avatar
  • 363
1 vote
0 answers
345 views

Custom post type showing index.php

I am creating a theme and I have created a new Custom Post Type (CPT) called 'Custom Plugins'. I am trying to get this CPT to use its own template. I have created a single-custom-plugin.php - it doesn'...
user avatar
1 vote
1 answer
25 views

redirect automatic page that serves custom posttype content

I registered blog as a custom post type. This content is queried on the page page-actueel-blog. But mydomain.com/blog also serves content (by default titles are queried). I don't want visitors to ...
user avatar
  • 51
1 vote
1 answer
150 views

How to overwrite core/libraries/vendor template with child theme

A theme that I am using is overwriting the woocommerce templates with files in theme/core/libraries/vendor/woocommerce/templates folder. I tried to overwrite some minor stuff by following the best ...
user avatar
  • 111
1 vote
1 answer
542 views

How To Pass Current Post Type ID from Single Template To Custom Page Template

Having a Custoom Post Type called movies, I am able to get the current Post ID in my single-movies.php template. Now can you please let me know how I can pass this post ID from the single template to ...
user avatar
1 vote
1 answer
20 views

Having trouble with Template hierarchy. I Need to create a set of pages that drill down from states to specific locations

I am creating an interactive set of pages that needs to be very easy to navigate, as the audience skews older. Walking through the flow The user will start at a page, that lists all of the (US) states....
user avatar
0 votes
1 answer
27 views

Static page won't identify template

I have two pages, one working correctly and one broken. The first is called Calendar and it has an ID of 34. I created a page template called page-34.php and wrote some custom code, and when I load ...
user avatar
2 votes
2 answers
8k 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 ...
user avatar
0 votes
1 answer
43 views

inserting content of 1 Post to in another with a template hierarchy

I have a page template I use for landing pages for various ad campaigns. The template uses custom fields for things like headlines and other shorter pieces of content within the page. However the ...
user avatar
  • 191
0 votes
1 answer
101 views

Templating advice sub posts of a CTP

Im looking for advice to generate a few 'default' post templates. Currently this is the setup for the CPT 'projects'. We generate subpages and select the main post type as parent. This works well to ...
user avatar
  • 131
2 votes
2 answers
241 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 ...
user avatar
2 votes
1 answer
356 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.
user avatar
  • 198
0 votes
0 answers
30 views

which template should I use for single category post?

I have a category 'c program'. I can show this category using category.php template file. I have a post like 'First C program' under 'c program' category. So I want to use another template file for ...
user avatar
0 votes
0 answers
34 views

custom post template not getting picked for posts with Unicode title

We have a custom post type called support. And we have created a template for it as single-support.php. The problem is when we crate a new post with English slug it works fine: eg. www.mywebsite.com/...
user avatar
0 votes
1 answer
28 views

Specific template for subcategory of custom taxomy

I've a custom post type that I manage with a custom taxonomy. I've made a template: taxonomy-brand.php, to show the top level categories of the taxonomy. Now I'd need to show the subcategories of each ...
user avatar

1
2 3 4 5