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
1
vote
1answer
112 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 ...
1
vote
2answers
64 views

Trying to manage templates on a blog with lots of custom taxonomies

In my most recent project, I'm dealing with a website that included dozens of custom taxonomies, couple of post types, content, etc. and required different templates for different authors or tags. ...
1
vote
2answers
2k views

Load parent theme files before child theme functions.php

I am creating a theme framework to use in future wordpress themes that I develop. I would like to include dependant files such as classes inside the parent theme before the child theme functions.php ...
1
vote
2answers
5k views

Custom Taxonomy term archive template

Is it possible to have separate archive templates for custom taxonomies? Like this: Tax(categories) -Players(category) -Managers(category)
1
vote
2answers
4k views

index.php template is used instead of blog page

I am trying to set WordPress so that home page is static, and the blog page is a separate page. So, I created two page templates in my theme., lets call them home_template and blog_template. Then, I ...
1
vote
1answer
95 views

where is the code that executes the template hierarchy?

I can see a picture of the template hierarchy here, but where is the actual wordpress code which decides that it's a "category page" or an "archives page" or a "search page"?
1
vote
1answer
45 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: ...
1
vote
3answers
657 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 ...
1
vote
1answer
747 views

When a link doesn't exist, how to tell Wordpress what to do? (404 Error Page)

If you click any link that doesn't exist in my main site site, for example this link, i expect the WordPress to use the default index.php file that has this loop inside it: <div class="main col &...
1
vote
3answers
651 views

How to Handle CSS for Multiple Header header.php Files?

So, I'm building a new theme based on Underscores. So far, I've managed to get ACF Pro to call different header files from a dropdwon selction in the Options page but, now I am faced with the task of ...
1
vote
1answer
134 views

Is there any way to get all the name or slug of template parts used in a page?

I am developing a custom plugin where I am using a single page template and changing the template parts only using ajax,I want to retrieve the template parts slugs or name (like custom-header.php, ...
1
vote
2answers
134 views

Simple way to get two language WP site

I am trying to make a site with two languages. I was looking for a solution and didn't find a simple how-to answer. Also, I prefer not to use plugins when it is possible. What I'm trying to do: 1) ...
1
vote
1answer
620 views

Template Hierarchy tag-{slug}.php directory

When tag-{slug}.php is in the root of theme, say wp-content/themes/p2/tag-{slug}.php, the template hierarchy is respected. However, I have many such custom files and just cannot have it in the theme ...
1
vote
4answers
3k views

Create static front-page with 3-5 recent posts

I am struggling with front/landing page customization for my custom designed theme. I have designed custom theme and pretty much coded it using the Underscore boilerplate. As I understands, the ...
1
vote
3answers
3k views

WordPress Ignoring My Custom Post Type Templates?

WordPress is 404ing all of my Custom Post Type posts. Have I missed a step here? I’m using the following to set up my CPT: function custom_post_types() { register_post_type( 'creativework', ...
1
vote
1answer
3k views

Custom post type not using it's own single-postname.php

I have a custom post type (that I'm using on a template page), the custom post type is called 'headerhome'. When I post say a gallery there I'm trying to get it to redirect to 'single-headerhome.php', ...
1
vote
1answer
42 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/...
1
vote
1answer
127 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-...
1
vote
1answer
553 views

Override template file i subfolders

What is the correct way to override theme template files in subfolders with a child theme? I wan't to override a theme template file with the following path: /components/theme-header/ Do I have to ...
1
vote
2answers
1k views

Category-slug.php not being used

I have this category-newbie.php template in my theme. And I have the category "newbie" in categories, but it is not using newbie it is using the category.php EDIT:
1
vote
1answer
66 views

Custom post type templating problem

I have a custom post type named 'product', with taxonomies 'brand' and 'type'. I'd like to have Archive Page A: sidebar with all the 'brand' terms linking to their respective archive page list of ...
1
vote
1answer
1k views

Is there a way to set different post templates for parent posts and child posts in the same post type?

After taking a look through the questions suggested to possibly have my answer, I still can not seem to find something that I references the post-template php files. I have two custom post types that ...
1
vote
2answers
1k views

How to Arrange PHP Files to Allow for Multiple Types of Pages?

I am new to WordPress development (the most I've ever done on the web design/development side of things is creating basic HTML sites); so this may be an extremely simple question, but I am trying to ...
1
vote
1answer
657 views

How to make use of WP templates within a nested site structure?

I am working on a site that highlights neighborhoods. Within each neighborhood there are places (that will be added by the client on the back end). Each neighborhood will have its own unique set of ...
1
vote
1answer
723 views

Single page site with history.js

I'm developing a single page site that shows each page on the front page, like so: *-----------------* | Home | ...
1
vote
1answer
325 views

is_home() returns TRUE on page template

I'm wondering why my link: http://localhost/?page_id=3433 returns TRUE on is_home() usage: if(is_home()){ var_dump(is_home()); die('test'); ...
1
vote
1answer
134 views

Wordpress Page Hierarchy

I have the following page on a site in development: http://telamon.com.s137737.gridserver.com/media/press/ I want to do some stuff outside the loop, so I created page-press.php based on my ...
1
vote
1answer
276 views

How do I create a custom archive page depending on the custom taxonomy type?

I've created a custom taxonomy called 'productCategories' using register_taxonomy() function. I've set the rewrite slug to 'products'. My question is: How do I render a different template to archive....
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
226 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
41 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
261 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
18 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....
1
vote
1answer
222 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
0answers
99 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
1answer
183 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 ...
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
1answer
573 views

Categories overview that links to page displaying posts

I am trying to achieve the following A page that displays a series of categories with a title, description and an image When a category is clicked, all posts that belongs to that category gets shown....
1
vote
2answers
1k views

Custom templates vs page-slug

I've currently been using the slug to set the page template, using the normal hierarchy For example, if I wanted to change the page template for http://www.example.com/about-us, I would edit page-...
1
vote
0answers
142 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
247 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
490 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", "...
1
vote
1answer
474 views

Single page template for custom post_type

I registered a custom post type with the following code: #Register custom post type for Stars of the Month add_action( 'init', 'sdp_create_star_type' ); function sdp_create_star_type() { ...
1
vote
2answers
198 views

Static Front Page problem

My theme uses the front-page.php file to display a number of items on the front page including a slideshow and some featured items. I have also designed it so the static front page as set in the ...
0
votes
1answer
35 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 ...
0
votes
2answers
96 views

Understanding the Template hierarchy

I've got a template called News. When I go to the Dashboard and edit the Page called News which has a web address of news.html I can see it uses this template (i.e. in the Page Attributes > Template ...
0
votes
2answers
2k views

How does WordPress choose archive type template?

I can't find a comprehensive list of criteria for how WordPress determines which archive type template it chooses. From what I understand it uses URL forms for this purpose, like: example.com/...
0
votes
3answers
3k views

How can I conditionally show different home page templates based on whether or not the user is logged in?

How can I conditionally load HTML for the home page based on whether or not the user is logged in? Currently my theme has an index.php file. In that file I tried to create: <?php if(...
0
votes
1answer
9k views

the_excerpt() in content.php and get_template_part() in single.php

everybody. So I'm creating a blog theme and have put the_excerpt() in content.php My index.php displays different post excerpts for the different kind of posts-formats. I have content-gallery.php, ...