If you know you’re loading the right template, redirect to your first term of the specified taxonomy:
function wpse_135306_redirect() {
$cpt="countries";
if (is_post_type_archive($cpt)) {
$tax = 'cities';
$args = array(
'orderby' => 'id', // or 'name' or whatever
);
$cities = get_terms($tax, $args);
if (count($cities)) {
wp_redirect(get_term_link(reset($cities), $tax));
exit();
}
}
} // function wpse_135306_redirect
add_action('template_redirect', 'wpse_135306_redirect');
References:
Related Posts:
- pre_get_posts with tax_query causes empty result
- Sort Custom Post Type Archive by Taxonomy Term [duplicate]
- How to group by taxonomy on Custom Post Type archive
- How to include parent terms in hierarchical taxonomy URLs?
- How do I get WordPress URL rewrites into Sitemap?
- Custom Taxonomy template is not recognised
- How do I Use Multiple Loops with WP_Query?
- Custom Taxonomy Template Error: Catchable fatal error: Object of class WP_Error could not be converted to string
- Get number of post who belongs in two taxonomies!
- How do I exclude posts from custom taxonomy from a custom post type archive?
- Automatically Give All Custom Post Types a Pre-Set Category [duplicate]
- Redirect on saving term at custom taxnomy
- Taxonomy Rewrite Rules Redirecting Instead of Masking
- I don’t need ‘view’ page for my custom taxonomy
- Check If Taxonomy A and Taxonomy B has same Slug, 301 Auto Redirect Tax A to Tax B if True in WordPress
- Why isn’t the ‘no results’ being shown when a query returns no results?
- Reverse order of posts in a certain taxonomy archive?
- Custom taxonomy link automatically removing query string and re-directing
- Best way to redirect taxonomy terms to pages
- forward/redirect taxonomy archive of term to a page with same name
- pre_get_posts post_meta event
- Template file renders on local install, not on web
- Need equivalent of single_term_slug
- is there a way of getting term children that only shows those from two taxonomies
- Main query disturb pre_get_post by category query
- How to show category list in WordPress
- Change the Page Title of the Archive Page for Portfolio Tags
- index.php Not Showing Custom Posts / Terms
- If term and page have the same slug, how can I view the term archive?
- stdClass::$labels /wp-includes/general-template.php undefined
- Using post type archive page for taxonomy archive
- add_rewrite_rule pagination 404 error on page 4 and above
- Add custom display condition to Elementor Theme Builder for custom taxonomy children, grandchildren, and great-grandchildren
- How to return custom taxonomy term in title for archive?
- How do I get the top-level terms in a custom taxonomy?
- wp_options table value
- Count number of post in Taxonomy?
- Post type archive page not working
- wp_query orderby title and meta key value (WP3.1)
- custom taxonomies on permalink
- Manipulating cookie on specific taxonomy archive page
- Archive or taxonomy pages not working for custom post type
- Category page and edit post page with this category very slow
- Custom Taxonomy tree view not showing correctly in backend
- Get custom field values of taxonomy terms
- How to List Parent Term Links for Custom Taxonomy With & Without Children?
- Correct Way To Show Custom Taxonomy for Image Attachments on Template File
- Single reusable value for post meta: Custom Taxonomy or Post Meta?
- 404 for a custom taxonomy?
- How to display featured images for all posts with certain taxonomy label?
- Create multiple rewrite endpoints for custom taxonomy archive
- Get child product categories from parent product category in WooCommerce
- Display only first level children of my custom taxonomy categories
- Register Taxonomy earlier so it can be used in functions.php and admin-ajax.php
- echo current taxonomy id for this loop?
- Add “All Posts” button to custom post taxonomy filter with ajax in wordpress
- get_terms adds slaces to the resualt
- Meta description – template code to get category description
- Posts in loop displaying all taxonomies
- Create template for taxonomy results limited by Custom Post Type
- Custom Taxonomy in REST API
- WordPress thinks my custom taxonomy pages are search pages #seo
- how to change permalinks format for pagination?
- Getting WooCommerce product related child categories
- How to fetch the data from Advanced Custom post when we search specific keyword or field name related to the post?
- Custom Post Archive is not working
- 2 custom post-type and 1 taxonomy
- Forcing a term/taxonomy on all posts of CPT
- Displaying Custom Taxonomy without a hyperlink
- Is it safe to register a taxonomy without using any hooks?
- Alphabetically sort a taxonomy.php template by post title
- My custom taxonomy page is leading in 404 page
- Display a specific hierarchical level of a specific custom taxonomy
- Display Custom Taxonomy names
- Different Taxonomy Values for Each Post
- Custom taxonomies not showing up in admin menu
- Get list of taxonomies associated with users
- check if a taxnomy queried in $wp_query?
- why the archive of custom taxonomy term shows nothing?
- passing moree than one value of slugs in taxonomy using variable
- Items from media library won’t get added to a custom taxonomy
- Custom field with terms from another taxonomy programmatically
- Taxonomies and subtaxonomies relations
- Building Link List for Custom Tax
- Retrieve & Display User Meta Values from Checkboxes
- Custom taxonomy if statement
- Group & Sort Taxonomy terms by letter – Is there a better way?
- Custom taxonomy in custom post type archive with pagination
- Add image to taxonomy and output to homepage
- Trying to Display Number of Posts in Term
- Multiple taxonomies, what should the permalink look like?
- Determine if Term has Grandparent/Great-Grandparent
- add_query_arg to look up page title
- Loop custom post type by taxonomy (Category)
- Create heirachy of post terms from array & assign post to terms
- Hook to filter based on form value and insert term
- Change get_author_posts_url / Author URL via filter
- Prevent random entries in hierarchical false taxonomies
- Exporting CSV of users with custom user taxonomies out of WordPress
- Sub-pages of Custom Taxonomies