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
11 views

How to assign a single-menu-template to a menu-items in a taxony/ cat/ subcat/ subcat-item

Hi hope really someone can assist. I have created a single-meny-template with post-type-meny, and I have created taxonomy, categories, sub-categories and subcat-items. What happens is that the ...
Brango's user avatar
  • 1
0 votes
1 answer
44 views

Unload templates; disable parent Template Parts using only "theme.json"

I'm currently creating a child theme in WordPress and I'm having trouble with template parts and custom templates from parent theme. In particular, I want to disable some of the template parts ...
Vladan's user avatar
  • 101
0 votes
2 answers
71 views

Template hierarchy html with taxonomy in 6.2

Following the doc: for a single post wpress 6.2 loads single.html ( and if none index.html) ok. If we follow hierarchy diagram, a post with specific taxonomy XX will be : single-XX.html ( ie single-{...
pirela's user avatar
  • 101
0 votes
1 answer
29 views

I'm building a WordPress theme and noticed that the 404 page template runs along with the corresponding templates for each page. Any idea why?

function debug($message){ error_log($message, 3, get_template_directory() . '/debug.log'); } I added the above function to each of the templates. For example, front-page.php includes a line that ...
SuPalle's user avatar
  • 11
0 votes
0 answers
43 views

Different template fallback when changing permalinks

I am creating my own WP theme from scratch. Super basic stuff. But something drives me nuts. First of all, took me long time to realize that the page with all the posts is home.php. I thought it would ...
Arwin Visser's user avatar
0 votes
1 answer
28 views

How did WordPress link an empty page at dashboard to an actual php file?

I set these 2 settings under WordPress dashboard » Reading: Homepage dropdown: set to home (an empty wordpress page I created in dashboard). Posts page dropdown: set to blog (an empty wordpress page ...
compliance's user avatar
0 votes
0 answers
57 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
0 votes
0 answers
631 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?
mm42's user avatar
  • 1
1 vote
0 answers
16 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 ...
Calin Diea's user avatar
0 votes
0 answers
43 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/, ...
alancc's user avatar
  • 41
0 votes
2 answers
22 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
801 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 ...
Nomikos Strigkos's user avatar
0 votes
1 answer
16 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&...
Pelmi's user avatar
  • 3
1 vote
1 answer
857 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 ...
lucrece's user avatar
  • 114
0 votes
0 answers
21 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/...
ardv's user avatar
  • 1
1 vote
1 answer
243 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 ...
Trees4theForest's user avatar
0 votes
1 answer
207 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-...
Krys's user avatar
  • 135
0 votes
1 answer
256 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 ...
JimDon's user avatar
  • 13
0 votes
1 answer
69 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 ...
Daveh0's user avatar
  • 189
1 vote
1 answer
246 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 ...
kanlukasz's user avatar
  • 464
1 vote
2 answers
2k 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 ...
Yusuf Been Hashem's user avatar
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: ...
butterchikita's user avatar
1 vote
1 answer
299 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/...
mrKC.988's user avatar
1 vote
0 answers
48 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 ...
sialfa's user avatar
  • 319
1 vote
1 answer
2k 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-...
Christian Watson's user avatar
3 votes
1 answer
505 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 ...
Henry's user avatar
  • 983
0 votes
1 answer
232 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 ...
Mikey's user avatar
  • 101
0 votes
0 answers
39 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 ...
JJ Gerrish's user avatar
0 votes
1 answer
225 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 ...
Aravona's user avatar
  • 565
0 votes
0 answers
234 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
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 ...
jonnyK's user avatar
  • 91
0 votes
0 answers
29 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 ...
nathanbweb's user avatar
0 votes
2 answers
312 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 '...
sergekol's 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 ...
Lucas Vendramini's user avatar
2 votes
2 answers
77 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 ...
Abdul Sadik Yalcin's user avatar
0 votes
1 answer
89 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 ...
gordie's user avatar
  • 482
0 votes
1 answer
504 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 ...
Yossi Aharon's user avatar
3 votes
1 answer
590 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 ...
Robert Andrews's user avatar
0 votes
2 answers
56 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 ...
Victor Oliveira's user avatar
0 votes
1 answer
1k 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-...
Ben's user avatar
  • 107
0 votes
1 answer
29 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. ...
user13286's user avatar
  • 403
1 vote
0 answers
375 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'...
D. Winning's user avatar
1 vote
1 answer
28 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 ...
Ludo's user avatar
  • 51
1 vote
1 answer
209 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 ...
Stoinov's user avatar
  • 111
1 vote
1 answer
753 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 ...
Mona Coder's 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....
Tim King's user avatar
0 votes
1 answer
28 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 ...
ConorBaumgart's user avatar
2 votes
2 answers
9k 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 ...
Sanjay Goswami's user avatar
0 votes
1 answer
47 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 ...
Daveh0's user avatar
  • 189
0 votes
1 answer
112 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 ...
Duikboot's user avatar
  • 131

1
2 3 4 5