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');
Related Posts:
- Categories overview that links to page displaying posts
- is_archive() content being shown instead of is_category()
- Which php file lists all the post of a category
- What Must to Display the “mysite.com/category” URL?
- Category link redirect to custom template page instead of index.php?
- Custom Archive Template for Multiple Categories
- Use different file includes for single.php
- Most efficient way to have 1 template for parent, 1 template for child categories?
- Template files not working for archives and categories
- How can I display the number of post associated to a category in Twig/Timber WordPress? [closed]
- Having a template per category? Bad for server overhead?
- Is it possible to have a template that works on multiple categories where the link address contains the specific category?
- Echo text using is_tag
- custom page for custom Taxonomy
- Custom template for sub-sub-categories
- Custom page category taxonomy 404
- Template hierarchy: how to let category.php conditionally-load archive.php?
- Filter By Category Dropdown List With Custom Taxonomies
- query_posts by category_name and custom taxonomy
- How to use wp_list_categories with plugin category?
- Using if statement in index.php instead of creating separate template files
- Is it possible to create an alias/custom taxonomy for a category name?
- Why is my sub-category template showing the wrong posts
- Same menu for different taxonomies to reach different content
- Template for product-category page [closed]
- Add Date & Author Meta to Category Archive Page
- Showing HTML if Post is In Certain Taxonomy Term
- Display subcategories selectbox on each category page
- I need to exclude from a query a category and a few custom taxonomies
- Displaying year once in category.php [duplicate]
- how to access the $query variable inside taxonomy-xxx.php template file?
- I would like to feature a tip on the homepage
- How could I write a get_categories_by_year() function?
- How to load several hierarchical categories from functions.php
- Assign a custom post to a custom taxonomy based on custom field value
- How to differentiate the homepage structure from the category page structure in WordPress template?
- Posts not listing out sub category in hierarchy
- Post to inherit custom category background image from parent
- How can I include custom category and tag base in template files?
- Different header for each category
- Category Template – Show Last Entry as Featured
- Custom Fields Value As Taxonomy
- Custom post type archive category page results in 404
- How to get posts using category slug in ClassiPress?
- Include home page template in specific category template
- 3.1 post formats and specific categories/custom taxonomies
- Link posts together (relative, not grouped)
- Output Title of Post’s Current Category
- Showing different posts on category pages
- Displaying categories in different template problem
- How to fix select filter on category
- Migrate the posts of a category to another blog as a custom taxonomy
- Include last post date in get_categories loop
- How to list posts from a sub-category that is listed in a parent category (more details below)?
- List of post categories only associated to another custom taxonomy
- List taxonomy terms assigned to a post in hierarchical view
- Page category filter in admin dashboard
- Automatically add custom taxonomy to posts in a category
- How to set the same base url for two different taxonomies?
- Taxonomy custom check box meta field not getting saved
- Ordering terms whilst in loop
- When creating a new product, auto assign it to all custom taxonomy woocommerce
- Grab all the posts for particular category
- Get WooCommerce product category list in functions.php
- How can i echo next and previous custom category from a Taxonomy
- How to load terms of a custom taxonomy of a product in woocommerce cart page
- Using heirarchial tags or Custom taxonomies
- How to assign Categories and tags inside the TinyMCE Editor for each Image?
- taxonomy – templates are not loading
- Category custom template is not showing correct posts
- Templates for CPT not working
- Single taxonomy for different custom post types
- Why use hierarchical taxonomies instead of many custom taxonomies?
- Renaming default category taxonomy?
- Adding a category view to a page
- Most efficient way to display current post subcategories?
- Using a template page parent breaks page
- Different template for subcategories
- How to Manage and link certain custom taxonomy?
- the_content() not showing full posts in category template
- Dynamically creating content on custom URL without getting 404
- Display List of Categories Within a Custom Taxonomy
- How to exclude category and post_tag taxonomy while displaying custom taxonomy?
- New Category – custom taxonomy
- Display Taxonomies in loop with template args
- Choosing different templates for categories
- Show posts from all categories
- How to add a post with new Taxonomy without assigning to default category?
- How to add additional field to Add new category part (without plugin use) [closed]
- Getting page/category content to show up in my custom page template
- List Terms by category
- Category and tags goes 404
- How to display custom taxonomy
- Category Templates for Post Types not Working
- How to create default categories in new installs?
- One category not displaying template updates
- Most efficient use of custom taxonomies, categories, and pages
- Create Cross Promoting Categories in WordPress Using ‘pre_get_posts’
- Check if value is a custom taxonomy category name
- WordPress doesn’t respect the template hierarchy?