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
- Get term name from term ID?
- Can custom taxonomies be displayed inside of a custom meta box?
- Front End Post Save Child terms
- Display child taxonomy until the last child
- URL rewrite rules for multiple taxonomies query
- Best practices for complex taxonomies
- wp_get_object_terms – How can I order the resulting array by hierarchy?
- How to display and use all existing tags at my write-post-at-frontend-panel?
- How to use create_term, edit_term, delete_term actions?
- Hierarchical display of custom taxonomy
- custom post type category page
- Advanced custom fields – taxonomy terms images [closed]
- How to get parents of custom taxonomy, as what get_category_parents() do?
- How can I display all post IDs from the taxonomy?
- Woocommerce custom taxonomies page
- Keep taxonomy base name in post permalinks
- Outputting an array of term meta values in a custom WooCommerce tab?
- get_terms: determine if taxonomy term has children
- Is it acceptable to build functionality into a theme built for a client? [closed]
- Set a taxonomy as private
- “show option all” on list categories doesn’t display taxonomy
- get_term_children returns WP_Error for custom taxonomy
- Category taxonomy template not working for custom post
- Displaying terms by first letter
- Same taxonomy for different object types
- Enable the admin to sort custom taxonomy
- Translating a custom taxonomy
- Show all post of taxonomy on base taxonomy URL
- Taxonomies for custom post types
- Taxonomies image
- Display custom post type category, while in a CPT category, then the posts beneath
- How do I modify taxonomy term slugs dynamically?
- Pagination on Custom Tax Pages Removes Spaces from Query Vars
- Does using custom taxonomy is more CPU efficient than using meta_data?
- WP REST API – get custom taxonomies based on terms & filter
- Using WP_Query and Query_post for the loop?
- Multiple Custom Taxonomy Dropdowns Lists
- Double slash in the_terms URL
- Using custom taxonomy when registering a new custom post type
- How to call a custom taxonomy term name inside a function?
- Get custom taxonomy name (not the term) in custom post
- How to add custom content to custom taxonomy
- query to use to link to taxonomy single page
- Fix Custom Taxonomy Display two times on each call
- Update Custom Taxonomy Value for a post based on custom date field
- Saving custom taxonomies to post as checkbox on frontend
- Custom taxonomy permalink without term, redirection to CPT slug
- How can I show links for custom posts group by taxonomy current term and sub-term?
- Show custom taxaomy as a product meta
- Rewrite Search URL Permalink For CPT Custom Taxonomies
- Updating a custom post type’s custom taxonomy in a custom editor block
- Template taxonomy-{taxonomy}.php doesn’t show my posts
- Custom taxonomy – no posts found
- How to truncate the description in the admin panel for a custom taxonomy
- Custom post type archive page not showing on archive-posttype.php
- Custom button on custom taxonomy listing page
- Custom Taxonomy Archives Page Errors
- customize taxonomy Page
- Remove taxonomy menu without removing the metabox?
- Custom taxonomy list in Worpdress
- How can I show custom field according to taxonomy?
- Insert code on specific taxonomy archives
- get_term_children specific no id
- custom texonomy category child category list with parent head
- is_tax not working for custom taxonomy
- wp_add_object_terms cant recognize a post ID
- Foreach for get_the_terms for hierarchical taxonomy don’t repeat Top Level Terms if contains multiple Second Level Terms