Is it possible to have an index page for taxonomy term for each custom post type it is assigned to?

A simple method would be to create a archive template file for the location taxonomy, and then include the proper inner-template for each post type. First, create a PHP file in your theme’s root folder, named taxonomy-location.php. Then, you can use get_post_type() insider this template the include the proper template: get_template_part( ‘templates’, get_post_type() . ‘-content’ … Read more

How to use same theme template for multiple taxonomy terms?

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

Different templates for parent and children categories/taxonomies

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’);

Different template for subcategories

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)