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
- Permalinks: custom post type -> custom taxonomy -> post
- Mixing custom post type and taxonomy rewrite structures?
- How do I append multiple taxonomies to the URL?
- WordPress Rewrite Rules for Custom Post Type and Taxonomy
- Permalink Structure for Multiple Post Type Archives by Taxonomy
- Remove slug in taxonomy url
- Taxonomy, Terms, and Template Files
- Permalink rewrite 404 conflict- WordPress Taxonomies/ CPT
- custom post type and custom taxonomy permalink
- Is there a way to use regular categories with custom post types?
- Dynamic taxonomy in permalink made all other posts NOT FOUND?
- Custom Post Type Permalink For Parent/Child, 404 Page Not Found Error
- Help with a TV series Rewrite structure
- Rewrite permalinks for custom posttype and custom taxonomy
- How to check if last uri segment is a custom post type or taxonomy term?
- Custom permalinks – post type – hierarchical taxonomy’s
- Custom taxonomy & post slug permalink
- Including two taxonomies in a permalink structure
- WP Rewrite Rules – Custom post type & taxonomy
- Remove base slug in CPT & CT, use CT in permalink
- Permalink Structure problem with cpt and custom taxonomy
- Custom Taxonomy List links being re-written
- Page to display an archive of taxonomies
- Custom Post Types, Custom Taxonomies and Permalinks ?
- How to create a permalink for custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- Custom post type permalinks giving 404s
- Custom Taxonomies: Multiple Hierarchical Permailnks For A Single Post + Prev/Next Links
- How to show custom taxonomy in the permalink?
- Add the .html extension to custom post types
- Date-based permalinks for Custom Post Type, and custom taxonomy permalinks
- What is better: Custom Fields vs Custom Taxonomies with Terms for perfomance, scalability and better user experience
- Custom Permalink Tag breaks Pagination
- Custom Permalink with Dynamic Taxonomy for Custom Post Type – Works, but breaks other permalinks
- Custom Permalink for Taxonimie and Custom Post Type
- Custom Taxonomy breaking pages permalinks
- Permalinks for custom post-types within custom taxonomies not found
- removing custom tax & CPT slug, adding taxonomy term in front of custom type
- Custom post type and taxonomy permalinks – Structure
- Custom Post Type and Custom Taxonomy Permalinks
- Custom Post Type with two hierarchical Custom Taxonomies: strategy to generate best permalink structure
- Custom post types and permalinks
- Permalink Structure CPT With Custom Taxonomy Fails
- Parent & Child Taxonomy slugs in custom post permalink
- Change Permalink Structure for Tag.php template
- Use different taxonomies in different custom post types’ permalinks?
- 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?
- 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?
- Can’t remove front from permalinks for custom taxonomy category page
- Removing custom post type slug from URL
- Customize Custom Post Type URL
- 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
- How to have this permalink structure: post_type/postname/custom_inner_page
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- Custom taxonomy returns 404
- How to change permalink to include custom post type
- Custom post type, permalinks, taxonomies and blog posts
- permalink /category/post-name with custom post type and taxonomy
- Best way to specify “article type” in URL
- Template files for Custom Post Type and Taxonomy
- Template for custom post type when taxonomy is in the URL
- How to filter a custom post type by custom taxonomy without 404
- Using page title as a link to term archive
- Is it possible to have hierarchical taxonomy and hierarchical custom post types in one permalink?
- Custom category URL not displaying posts
- Multiple permalinks for a single post with multiple taxonomies
- Duplicate slug/permalink issue while adding same post name
- Error 404 change permalink term custom term taxonomy
- How do you create pillar content pages?
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- How to change URL structure for custom post type in wordpress? Custom taxonomy + custom Post name [duplicate]
- % encoded URL giving 404 error in WordPress
- Remove CPT Slug with 2 taxonomies and 1 post meta
- Issue with Custom Post Types and Permalinks
- Custom post type URL structure with site.com/custom_taxonomy_slug/post_name
- Pretty permalink structure with multiple (AND OR) taxonomies
- How to have permalink structure based on taxonomy terms
- Multiple post types or single post type with category taxonomy?
- Custom Post type and Taxonomy in post URL error
- How can I add a “fake” parent into the permalink?
- How to retrieve the permalink for a specific (custom) term?
- Remove Custom Taxonomy Slug only without removing Custom post type slug in permalinks
- Adding 2 CPT with multiple custom taxonomies to permalinks
- WordPress Custom Permalink Structure with Custom Post Type and Taxonomies
- Add taxonomy to custom post type archive
- Permalinks Works for Custompost type but not with pages Why?
- Problem with Custom Post Types, Taxonomy, permalink, Archive
- Permalink for Custom Post Types
- 404 Error On Custom Taxonomy Pages 2, 3, etc
- 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
- Custom Post Types Do Not work on this permalink setting https://somedominaname.com/%category%/%postname%/
- How to get the proper category in permalink with custom post type assigned to multiple categories