So after some more research I came across this
https://stackoverflow.com/questions/23698827/custom-permalink-structure-custom-post-type-custom-taxonomy-post-name
– which I now think I remember using at some point but must have deleted thinking it hadn’t worked (as I hadn’t figured out the rest of the process). But this is the particular function and filter that worked:
/**
* Tell WordPress how to interpret our project URL structure
*
* @param array $rules Existing rewrite rules
* @return array
*/
function so23698827_add_rewrite_rules( $rules ) {
$new = array();
$new['news-media/([^/]+)/(.+)/?$'] = 'index.php?newsmedia=$matches[2]';
$new['news-media/(.+)/?$'] = 'index.php?news-media=$matches[1]';
return array_merge( $new, $rules ); // Ensure our rules come first
}
add_filter( 'rewrite_rules_array', 'so23698827_add_rewrite_rules' );
Related Posts:
- Custom post types, taxonomies, and permalinks
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- Permalinks: custom post type -> custom taxonomy -> post
- Mixing custom post type and taxonomy rewrite structures?
- Shouldn’t this be easy?! Custom post type/custom taxonomy permalink
- How do I append multiple taxonomies to the URL?
- WordPress Rewrite Rules for Custom Post Type and Taxonomy
- Custom Post type & Taxonomy URL structure
- Combining Multiple Taxonomies in one URL
- Permalink rewrite 404 conflict- WordPress Taxonomies/ CPT
- Why does a custom post type need the ”hierarchical’ args setting?
- Help with a TV series Rewrite structure
- array_pop() expects array, boolean given for $event_type_term ->slug
- custom post type permalinks with category and tags
- Permalink rewrite with custom post type and custom taxonomy
- Custom Post Type with Nested Taxonomy and Template Files
- Custom permalinks – post type – hierarchical taxonomy’s
- Semantic URL Custom Post Type and Taxonomies permalinks
- How to rewrite custom post type URL for multiple depths instead of one specific depth
- Page to display an archive of taxonomies
- How to create a permalink for custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- How to show custom taxonomy in the permalink?
- Date-based permalinks for Custom Post Type, and custom taxonomy permalinks
- Remove Taxonomy Slug when No Taxonomy is Assigned to Custom Post Type?
- Custom permalink – append taxonomy name and term name at the end of permalink
- Custom Taxonomy breaking pages permalinks
- Permalinks for custom post-types within custom taxonomies not found
- Add hierarchical taxonomy to permalink for custom post type
- Custom post types, taxonomies, and permalinks
- Custom post types and permalinks
- Parent & Child Taxonomy slugs in custom post permalink
- Custom Post Types and independent Categories – complex Taxonomy
- Use different taxonomies in different custom post types’ permalinks?
- custom permalinks based on taxonomies for custom post type
- Custom template won’t load for a custom post type (custom permalinks used)
- How to hook custom taxonomies to custom post types and make the permalinks work?
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- How to have the same url structure for both a CPT and a Taxonomy?
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- create a subcatagory for a custom post type and out put url as posttype/subcategory/item
- custom-taxonomy/post_name instead of the default post_type/post_name
- Show custom post archive when custom post not specified
- Show custom post type relationships by taxonomy
- Can’t remove front from permalinks for custom taxonomy category page
- Permalinks /country/city/cpt/postname/
- Seamless permalinks between Custom Taxonomy and Custom Posts
- Custom post type and custom taxonomy with the same slug using the file page taxonomy only as directory
- Custom Permalinks with CPT and Hierarchical Taxonomies
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- How to change permalink to include custom post type
- Custom post type, permalinks, taxonomies and blog posts
- set permalink for CPT
- How to solve this custom post type goes to 404 page?
- Permalink problems with custom post type and custom taxonomy
- Custom Post Type Advanced Slug
- WordPress custom permalink and archive link for custom post type
- Ideas on how to organize a project [closed]
- Enabling permalinks disables custom page template
- Change permalinks for custom post type based on taxonomy term
- Custom post type category permalinks and archive pages
- Safe to throw 404 error in request filter?
- Multiple permalinks for a single post with multiple taxonomies
- Set priority to permalinks
- Is there a way to use ‘publicly_queryable’ => false only on specific taxonomy term?
- How to prefix custom post type URL with custom post taxonomy term?
- How do you create pillar content pages?
- Changing CPT permalink
- Changing permalink of default Post with custom post
- Custom Taxonomy Archive generates 404
- Custom post type single with custom URL structure
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- Customise Permalink Structure For Custom Post Types
- How to create a permalink structure with custom taxonomies and custom post types
- Issue with Custom Post Types and Permalinks
- Pagination not working (page/2 retunring 404 page)
- Custom permalink with custom taxonomies for custom post type
- Template hierarchy changes when custom post-type permalink leverages custom taxonomy
- Associate custom CPT with another CPT’s taxonomy and rewrite permalinks
- Change the url of a custom post type to include taxonomy
- Post Custom & Taxonomy 404 error
- How to have permalink structure based on taxonomy terms
- Multiple archives for cpt, taxonomies, terms
- Same permalink structure for all post types?
- How to add base permalink to custom posts?
- Hierarchical taxonomy in permalink structure
- Permalinks when using Custom Post Type with static page for archive
- How to change permalinks to taxonomy and post type’s posts
- taxonomy term names in custom post type permalink structure
- Parent cpt/child custom post type URL permalink relationship
- Custom Post Type Permalinks Problem
- Change Taxonomy Permalinks
- Category / Custom Post Type permalink issue
- Adding rewrite rules to Custom Post-type mixed with Taxonomy
- Permalink for Custom Post Types
- Remove slug from Custom Category Permalink + dual-category permalinks
- How to have a dynamic slug and rendering the archive-{post_type}.php?
- Add /blog to the “post” post type url
- Two Permalinks with one Taxonomy (custom taxonomy) and (custom post type -> custom taxonomy)
- Modify permalink of CPT archive to support two taxonomies
- Have Custom Taxonomy Slug Fall Under Custom Post Type Slug