Assuming the code snippet provided works then extending the conditional statement like so will help you,
function filter_post_type_link($link, $post)
{
if ($post->post_type="custom_post_type_1") {
if ($cats = get_the_terms($post->ID, 'custom_cat_1'))
$link = str_replace('%custom_cat_1%', array_pop($cats)->slug, $link);
return $link;
} elseif ($post->post_type="custom_post_type_2") {
if ($cats = get_the_terms($post->ID, 'custom_cat_2'))
$link = str_replace('%custom_cat_2%', array_pop($cats)->slug, $link);
return $link;
} else {
return $link;
}
}
add_filter('post_type_link', 'filter_post_type_link', 10, 2);
Related Posts:
- Get Taxonomy Term Title by it’s URL
- Taxonomy in URL
- Custom Post Type URL Rewrite’s
- Force WordPress to only match URL in category
- Customize category URL
- Custom Post Type with multiple Custom Taxonomies / Hide Taxonomy Slug from URL
- Custom post type with custom taxonomies structure url not working archive of CPT
- Rewriting a custom-post-type permalink with taxonomy term?
- Add .html (dot HTML) extension to custom post types
- How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
- How can I rewrite URLs to pass taxonomy and post type values to the query?
- How to modify URL structures in custom post types and taxonomies or terms
- Custom post type taxonomies URL rewrite
- Create permalink structure for one taxonomy archive per custom post type
- Custom permalinks
- WordPress Custom Post Type Category Page
- Permalink rewrite with custom post type and custom taxonomy
- Issues when rewrite rules collide?
- Best Way to Leverage Custom Post Type Related Content and Consider SEO
- Custom Permalinks for Custom Post Types and Taxonomies
- WordPress returns 404 on custom rewrite rule conflict in parameters
- How to rewrite custom post type URL for multiple depths instead of one specific depth
- Custom post type category, taxonomy and URL rewrite problem
- Custom Post Type/ Taxonomy URL rewrite
- Category base to url in custom post type/taxonomy
- Is slug “type” reserved and can’t be used in taxonomy rewrite?
- Custom Permalink Tag breaks Pagination
- how to get archive urls with same origin for custom types and terms?
- Permalinks when filtering multiple custom post types by single taxonomy
- multiple url slug for single custom post type
- custom taxonomy archive by year
- custom taxonomy and custom post type url conflict
- Pretty URLs for Custom Post Type & Custom Taxonomy with Duplicate Slugs on WPML
- Custom Post Type and Custom Taxonomy Permalinks
- How can you handle rewrite rules for custom post types with option to filter on custom taxonomy terms?
- Query var removed after rewrite
- Custom taxonomy in URL showing 404
- Custom Taxonomy URL are redirecting to page with the same name
- Custom Post type and permalink settings
- wp_list_categories() – current-cat class also inside posts?
- Front custom edit post page for each post
- Adding custom post category slug in permalink causes 404 error for pages and posts
- How to build custom route by adding taxonomies to URL ? ex: www.demo.com/communities/palo-alto/
- How Can I Change the Custom Post Type Slug to the Taxonomy Slug in the URL?
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- create a subcatagory for a custom post type and out put url as posttype/subcategory/item
- Rewrite Question Mark in Post Template to Make it Pretty URL
- How can I make the slug of the taxonomy also the slug of the custom post
- How to rewrite url for any specific taxonomy?
- Custom post URL 404 error
- Custom taxonomy rewrite with query var returns %2F in URL
- Remove slug in URL custom post type
- URL rewriting for CTP assigned entity
- Custom taxonomy returns 404
- Including taxonomy term before post type breaks top level pages
- Correct procedure for advanced permalinks
- CPT’s with landing page instead of archive – Url Rewrite?
- How to get list of taxonomy slugs ordered parents>childs?
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- Custom taxonomy and post type with same slug
- Best way to specify “article type” in URL
- I can’t access custom taxonomy page listing
- post_type_link Filter – Too Few Arguments
- How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT
- How to create custom search result page with custom URL parameters for custom post type?
- How to rewrite the post slug of a custom post type post
- Urls in Custom Post Type work for Terms but not for its Taxonomies
- Custom post type URL
- Custom Post Type View Button in Admin Gives 400 Error
- Archive page for custom post type and custom taxonomy
- Custom taxonomy and post type rewrite rules
- Custom Post Type and Taxonomy Rewrite Error
- Custom taxonomy terms as children of multiple custom post types
- how to achieve this permalink abc.com/CPTName/CustomPostTypeCategorySlug/categoryname
- I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics
- Custom Post Type & Taxonomies – Rewrite
- Remove custom permalink base from CPT custom category and custom tags
- How to handle this wordpress custom post type rewrite problem?
- Display CPT taxonomies as an archive page
- Change CPT permalink to use the category
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- Customise Permalink Structure For Custom Post Types
- Custom URL for Custom Post Type & Custom Taxonomy Term
- Custom taxanomy and custom post type – pagination leads to 404
- Register post type getting error 404
- Flush rewrite rules when new cpt is registred
- What am I doing wrong with my taxonomy?
- I have a custom taxonomy assigned to two post types. How do I create URLs for different term archives for each post type?
- CPT url rewriting : regular posts return 404 error
- redirect old post type url to new structure url
- One custom post type with two different url structure base on taxonomy term
- Parent cpt/child custom post type URL permalink relationship
- Sorting custom post types by taxonomy (So close)
- How to change custom post type slug without damage seo? [closed]
- Links in archive not including taxonomy parameter
- Rewrite Rule for custom post type link with or without taxonomy terms
- Hide custom post type slug url from search engine [closed]
- Is it possible to use a post name in a custom post slug?
- Rewrite rule taxonomy url with different values in one function