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.

68 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
2answers
677 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
0answers
27 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 ...
1
vote
0answers
218 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
21 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 ...
1
vote
1answer
39 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
0answers
98 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 ...
1
vote
0answers
41 views

Wordpress Doesn't Generate Taxonomy Archive

I have a post type named 'publication' and a taxonomy named 'area'. For some reason, I cannot seem to get Wordpress to generate a taxonomy archive for the terms of 'area' from my custom taxonomy.php ...
1
vote
0answers
141 views

rewrite taxonomy-{taxonomy}-{term}.php terms

I try to figure out a rewrite problem, that is a somewhat over my head, so i ask here to find out what i can do. I use this two solutions from Jeff 1 and Milo 2, to get a full-path url for my custom ...
1
vote
0answers
246 views

How to use multiple archive templates for a taxonomy?

I have created a custom post type (product) with a taxonomy (brand). I need to have the basic archive pages (type A) and then custom ones (type B) to create a product comparison page which esentially ...
1
vote
0answers
482 views

WordPress Filtering Custom Post Type by Metadata and Search Heirachy

I have a custom Post Type called cptMovie which has two Custom Field (Metadata) "Language" and "Box office" assigned to it. I also have a Custom Taxonomy called movieTax with 4 tax Terms "Action", "...
0
votes
0answers
14 views

Force wordpress to load empty categories

If I don't have posts in a category, the category.php file won't load. This is a problem, because whoever built this custom template, used post categories to display woocommerce prodcuts (don't ask ...
0
votes
0answers
19 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 ...
0
votes
0answers
18 views

Loading a custom template file for plugin single page

I have had no end of trouble trying to load custom template files I create in plugins. I have got to the point where one is loading, but its like loading inside another template, if that makes sense. ...
0
votes
0answers
14 views

How to make Wordpress automatically load a page-$slug custom template, according to the URL?

I was wondering if there is a way to make Wordpress redirect to a certain custom page template, according to some "routing" convention. For instance, I've added a template file called page-docs.php, ...
0
votes
0answers
14 views

Removed slug from custom post type URLs page template issues

I use this function Remove slug from custom post type post URLs to remove slug from custom post type URLs .. but now I have issues... page.php is not working ... so now my pages with default template ...
0
votes
0answers
15 views

How to prevent the search results page from using my single-{post-type}.php template

I have created a custom post type which uses single-{post-type}.php to display when ever a page of that particular post-type is viewed and this works fine. When the search form is submitted the ...
0
votes
0answers
16 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 ...
0
votes
0answers
22 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 ...
0
votes
1answer
51 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
48 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
91 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
0answers
22 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
1answer
36 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
2answers
31 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 ...
0
votes
1answer
72 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 ...
0
votes
0answers
28 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
30 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
41 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 ...
0
votes
2answers
278 views

taxonomy - templates are not loading

I have registered taxonomy: $taxonomySetup = [ 'label' => __('Products catalog'), 'has_archive' => false, 'hierarchical' => true, 'rewrite' => [ 'slug' => __('...
0
votes
1answer
275 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
0answers
100 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
869 views

Creating page & post templates without template file

Usually if you want to customise a post (generic: ie all) type in WordPress you would create a custom page template for it ie, following the template hierarchy, a page will be customised based on it's ...
0
votes
1answer
444 views

Wordpress Custom Post Type - Post Attribute: Template. Template shows up and saves on the back end, but the default theme file is being rendered

Edit: Now I've found that this is Hybrid Core, and apparently the template hierarchy is different. I still haven't solved my problem below though. In addition to the title. My thinking is that if I ...
0
votes
2answers
219 views

Single taxonomy for different custom post types

I have two custom post types: books and authors. Both of them have attached a custom taxonomy - genres. How would I display the books in the fiction genre? What would be the URL used and the name ...
0
votes
2answers
68 views

Letting wordpress decide what template and page to use based on condition

I am really not sure how / what to ask, but ill try my best... Can I some how tell Wordpress (in the index.php file maybe): If A Then load page Y with his matching template (which you always know so ...
0
votes
1answer
123 views

Which template(s) to override to use a different sidebar for blog, single posts, categories, blog archive?

I'm setting up a News page as my site blog, and I want it to have a different sidebar from the one already used on the rest of the site. So far, I've managed to add a new widget area for my sidebar ...
0
votes
0answers
631 views

Archive or taxonomy pages not working for custom post type

I am trying to built archive templates for my theme , I am using plugin wp-job-manager which gives me following custom post type & taxonomies custom post type : job_listing 1st custom ...
0
votes
1answer
1k views

Manipulating show_on_front, page_on_front, page_for_posts and template hierarchy

I need to overwrite the show_on_front, page_on_front, page_for_posts options values for some reasons. I am setting show_on_front to 'page' and the other both to two different page id. If I change ...
0
votes
1answer
142 views

All top-level pages are using index.php as template

On my site, all top-level pages (i.e. mydomain.com/example-page as opposed to mydomain.com/parent/example-page) will only use index.php as their template. They won't use page.php, they won't use ...
0
votes
0answers
256 views

How can I modify wp_get_archives() to not use archive.php template?

If using wp_get_archives() or another query to display a year/month archive, the links for the months requires the archive.php template. Is there a function which can enable a different template to ...
0
votes
0answers
82 views

Page has no template

I've created a custom search for my custom posts, using the accepted answer from Creating a search form for custom fields. However, I'm struggling with the resulting page - I need to conditionally ...
0
votes
1answer
548 views

Is there a template file to list all terms of a given custom taxonomy?

Suppose we registered the composers and the interprets custom taxonomies. The composers taxonomy could have the following terms: Wolfgang Amadeus Mozart Ludwig van Beethoven Richard Wagner The ...
0
votes
2answers
233 views

Different taxonomy.php for different custom post types

I have taxonomy.php template file for post_type "posts" but I'd like to use another taxonomy.php but just use/apply it to a custom post type. Is this somehow possible to make another taxonomy.php file ...
0
votes
2answers
105 views

How to put articles under a /blog directory?

I have a homepage, work (as parent pages) and several pages (as child), but when it comes to articles, I can't choose the relation between them and the page Blog. Resuming, I can choose the hierarchy ...
0
votes
1answer
81 views

Single Post Templates Doubt

While I was reading template hierarchy. The single post template file is used to render a single post. WordPress uses the following path: single-{post-type}-{slug}.php – (Since 4.4) First, WordPress ...
0
votes
1answer
929 views

Templates for hierarchical custom post type

I'm a bit confused with templates for custom post types defined as hierarchical. I've got a CPT set to hierarchical, not strictly in order to have a nested hierarchy, but so that they can be ordered ...
0
votes
0answers
224 views

Use different file includes for single.php

I'm beginning to convet html to Wordpress, I've some problem in single.php to show the post with different headers because mysite use in English and Arabic language. My site containings Arabic and ...
0
votes
0answers
89 views

Custom Homepage As Single Page or Custom Post Type?

Conceptual question for the WP community: I need to implement a custom homepage for a new site. It has some custom stuff going on but nothing too crazy: 4 big images, a carousel, some calls to action ...