Re: Custom post types, taxonomies, and permalinks
by @TheDeadMechanic The solution above works perfectly, and rewrite is great, but can you advise on how to rewrite for more than one custom post type with its own taxonomy? the code below works for taxonomy product cat under products, but adding another CPT with taxonomy gives 404 as it not included below, how can the code below be amended to cater for more than one CPT and taxonomy?
function filter_post_type_link($link, $post){
if ($post->post_type != 'product_listing')
return $link;
if ($cats = get_the_terms($post->ID, 'product_cat'))
$link = str_replace('%product_cat%', array_pop($cats)->slug, $link);
return $link;
}
add_filter('post_type_link', 'filter_post_type_link', 10, 2);
thanks in advance
Assuming the code snippet provided works then extending the conditional statement like so will help you,