Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
2answers
43 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
13 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
48 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 ...
4
votes
1answer
68 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
26 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
91 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
32 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
18 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
92 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
21 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
53 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
17 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
20 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
507 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
29 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
33 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
67 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
68 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
16 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
26 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
58 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....
0
votes
1answer
70 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
43 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
26 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
76 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
143 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
30 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
15 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
116 views

taxonomy - templates are not loading

I have registered taxonomy: $taxonomySetup = [ 'label' => __('Products catalog'), 'has_archive' => false, 'hierarchical' => true, 'rewrite' => [ 'slug' => __('...
0
votes
2answers
113 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
367 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
70 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
99 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
252 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
40 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
78 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
56 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 ...
0
votes
1answer
441 views

bbPress: modifying template for forum index

I'm reading up on the bbPress help pages to try and find out how to modify a template but with little success. I see that WP will look for the following theme files and use the top-most first: ...
0
votes
1answer
30 views

What Must to Display the “mysite.com/category” URL?

I have WordPress 4.8.1 running a Twenty Seventeen child theme. When I try to open the *mysite.com/category* URL I get an OOPS! THAT PAGE CAN’T BE FOUND message. Is this a normal behavior? Can be ...
0
votes
1answer
408 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 ...
1
vote
1answer
109 views

How do I check if the user is on a taxonomy term parent, child or grandchild page?

I have a custom taxonomy: product_range and it has 3 levels: (1 - Parent) Product (2 - Child) Product Category (3 - Grandchild) Product Sub Category I need to display different content depending ...
0
votes
1answer
174 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
21 views

Custom TaxonomyTemplate

I have created a custom taxonomy brands and added some brands to various posts. I also created a file called taxonomy-brands.php and it seems to be working fine. If I visit www.domain.com/brands/...
0
votes
1answer
58 views

Templates & CSS - Proper Programming Practice?

I've worked with WP/html/css casually for a long while but never dug deep before, I have a few questions about good practices. My Background - totally skip this if uninterested I've been left ...