Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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
1answer
22 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 ...
0
votes
0answers
47 views

How can I include custom folder for the native hierarchy?

I want to put all the template files in certain directory in child theme. I also want to get the benefit of native wp hierarchy. I don't want to write code outside of that certain directory, and I don'...
0
votes
0answers
31 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 ...
0
votes
2answers
31 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 ...
0
votes
0answers
19 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 ...
0
votes
2answers
26 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 '...
1
vote
3answers
70 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 ...
2
votes
2answers
56 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 ...
0
votes
1answer
17 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 ...
0
votes
1answer
61 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 ...
3
votes
1answer
87 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 ...
0
votes
2answers
28 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 ...
-1
votes
3answers
264 views

page-{slug} not loaded in custom theme

I'm working on a custom template for WordPress. I've created some page and then created the relative page-{slug}.php (example page-careers.php) that are supposed to be loaded from WordPress when the ...
0
votes
1answer
65 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-...
0
votes
1answer
20 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. ...
1
vote
0answers
145 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'...
1
vote
1answer
20 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 ...
0
votes
1answer
24 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 ...
1
vote
1answer
123 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 ...
1
vote
1answer
15 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....
0
votes
1answer
18 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 ...
0
votes
0answers
25 views

Loop Query - How do I use WP_Query with the standard Wordpress querystrings?

I am wondering on the best way to approach a particular (common) scenario. I have a standard wordpress website, with various pages. I have one page currently designated to be the "blog" - this is ...
0
votes
2answers
1k 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 ...
0
votes
1answer
32 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 ...
0
votes
1answer
40 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 ...
2
votes
1answer
73 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
75 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.
0
votes
0answers
26 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 ...
0
votes
0answers
27 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/...
0
votes
1answer
17 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 ...
0
votes
1answer
27 views

My WordPress installation doesn't load correct template

For whatever reason there are some odd things going on with my theme, I feel like it's such a fickle install and some times I wonder how it runs. Anyway, I'm having a few different post types, ...
0
votes
1answer
62 views

How do I control what template is shown based upon Taxonomy Term?

I am building a business directory and will give some context and then have 2 questions at the end. The development URL is: http://svcta.lainternet.biz/ The website I am rebuilding is: https://www....
1
vote
1answer
96 views

Inheritance of parent theme plugin files in a child theme

I have parent theme that has some plugins in it, those plugins are added as a dependency. In the child theme, I want to override some of the files that belong to those plugins, but it looks like ...
1
vote
1answer
56 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 ...
0
votes
1answer
27 views

Selected template is not respected for home page in Wordpress

I have a theme, and I made two new files for different templates. I can now pick these templates when I post a page: This works perfectly when I go to any subpage. I made a page called Test, selected ...
1
vote
0answers
86 views

How to Rewrite Taxonomy URL to Include the Post Type as the Second Segment of the URL?

I have a custom taxonomy which is called locations which is assigned to post types which are post and events. What I am trying to figure out is how to rewrite the URL of the terms to also include the ...
3
votes
1answer
204 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 ...
0
votes
1answer
33 views

More than one search results page template for two searches on site

I have a site with two search fields, one on a page called 'blog' and one on a page called 'archive'. I am using <?php get_search_form(); ?> to call the forms. All of the sites posts are either ...
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 ...
0
votes
1answer
18 views

Can I assign a Folder for Post Formats, without it affecting WordPress' fallback/hierarchical system?

I have created a few Post Format Templates Files. format-aside and format-audio etc. At present, I am using <?php get_template_part (‘format’,get_post_format()) ;?> to call such Templates. In ...
0
votes
2answers
169 views

taxonomy - templates are not loading

I have registered taxonomy: $taxonomySetup = [ 'label' => __('Products catalog'), 'has_archive' => false, 'hierarchical' => true, 'rewrite' => [ 'slug' => __('...
0
votes
2answers
142 views

Custom Empty Results page for my Custom Post Type

I've been looking for the solution of this issue for a while but cannot find the correct answer. I'm developing a custom Knowledge Base plugin for my site, as requested by my boss. The around plugins ...
0
votes
1answer
516 views

Store Page Template Files in a Subfolder

I have number of legal documents of different formats / layout that I need to display on a Wordpress site, however I don't want to have them as individual page-pagename.php files in the root of the ...
0
votes
1answer
83 views

Template hierarchy override

One of the best way to override the default template hierarchy is to use the child theme and copy and paste the template file (from parent theme to the child theme) you want to override and change the ...
0
votes
1answer
127 views

Get link for taxonomy to show top-level terms

Is it possible to get a link for a taxonomy as such, not its individual terms? And to which page in the template hierarchy will this link point? Consider a hierarchical taxonomy called 'products'. ...
0
votes
1answer
324 views

URL Rewrite and Archive Template Files - Post Type vs. Taxonomy

I apologize if this is a difficult question to understand, but really it's a template hierarchy / rewrites question. I have set up a few rewrite rules that are successful, but I'm hoping that I can ...
0
votes
2answers
46 views

Avoid taxonomy-%term%.php if more than one taxonomy

I have a site with multiple custom taxonomies which are used for filtering posts. One of the taxonomies has a taxonomy-%term%.php template file. /?country=the_country shows the country taxonomy ...
0
votes
0answers
88 views

Templates for CPT not working

I am working on a project where I have created 3 CPT with some taxonomies. For each custom post type, I have created the following custom templates: single- archive- taxonomy- Taking as example the "...
0
votes
1answer
29 views

Will renaming a `content.php` file cause any problems?

I am currently creating a few templates for the various Blog formats, such as; 'Aside', 'Quote' and 'Gallery'. I see a lot of people create such Templates by naming such files as: content-aside....
0
votes
2answers
67 views

Different templates for each category level

I'm looking for a solution to dynamically create different templates for each category level. Category --Category ---Category ----Category I thought of something to get the taxonomy current level ...