How can I set up a category “overview” page?
There is no default rewrite to a template for a category or taxonomy landing page. You are correct, that this can be done by creating a custom template and applying it to a page.
There is no default rewrite to a template for a category or taxonomy landing page. You are correct, that this can be done by creating a custom template and applying it to a page.
You prepare templates (staying with your example): content-redfruits.php, content-greenfruits.php, content-fruits.php. Then in taxonomy file taxonomy-fruit.php (copy and rename taxonomy.php or index.php), before main loop check the term slug of the currently-queried object. $red_templ = [‘strawberries’, ‘tomatoes’, ‘raspberries’]; // term slugs $green_templ = [‘watermelons’, ‘apples’, ‘kiwi’]; // term slugs $template=”fruits”; $obj = get_queried_object(); if ( $obj … Read more
Your designated ‘blog page’ (selected in ‘Reading’) will use the index.php file (or home.php) rather than archive.php file.
I suggest creating 3 files 1) regiontemplate-country.php 2) regiontemplate-city.php These 2 will contain the templates for country & city, then 3) taxonomy-region.php In this file, add the code to load the appropriate template <?php $term = get_term_by(‘slug’, get_query_var(‘term’), ‘region’); if((int)$term->parent) get_template_part(‘regiontemplate’, ‘city’); else get_template_part(‘regiontemplate’, ‘country’);
One of the easiest (although not the only) of ways to achieve this is by creating a custom options panel in the WP dashboard that will allow your client to create and update information that can be used through out your template files with no technical knowledge being necessary. You can either paste the following … Read more
+1ed Pieter Goosen’s answer, but this time I want to be the one who advocate the “make it simple” way. In your taxonomy-earth.php template, you can check if the queried term as a parent, and require another template if so. If you ask this question, I guess you already have (or wish to create) 2 … Read more
As I answered here, since WordPress 4.7 Post-Type-Templates are enabled in the WordPress core. That means that you can create multiple templates for the single post-type view. You create these templates like you would create a normal page template. But you need to add a little more code to these templates: /* Template Name: Funerals … Read more
The template hierarchy has filters for all types of templates. Here we can use category_template, check if the current category has a parent, and load the subcategory.php file in that case: function wpd_subcategory_template( $template ) { $cat = get_queried_object(); if ( isset( $cat ) && $cat->category_parent ) { $template = locate_template( ‘subcategory.php’ ); } return … Read more
There is no specifica template for child pages, but you can do this pretty easily with the get_template_part() function. First create a file called “content-child.php”. Second create a file called “content.php”. Next, inside of page.php, place this: if( $post->post_parent !== 0 ) { get_template_part(‘content’, ‘child’); } else { get_template_part(‘content’); } Anything that you want displayed … Read more
If you’re concerned about the performance I would recommend using the WordPress API instead of trying to load markup using ajax. If you look at wp-includes/template-loader.php you can see how WordPress itself figures out which template to use. You could in theory just load that file, but you might have problems with template_redirect. require_once( ABSPATH … Read more