Sitemap showing rewrite placeholder instead of category for cpt
-
I’ve set up a product catalog website with a cpt Public Products which is coupled to a custom taxonomy Public Category. I’ve set up my cpt with a rewrite:
'rewrite' => array( 'slug' => 'prod/%tsrc_public_category%', 'with_front' => true, )
so my products live under the relevant custom terms. Eg prod/pots/antique-pots/brown-old-pot.
I’ve used a hook on ‘post_type_link’ to accomplish that:add_filter('post_type_link', function($post_link, $id = 0){ $post = get_post($id); if ( is_object( $post ) ){ $terms = wp_get_object_terms( $post->ID, 'tsrc_public_category' ); if( $terms ){ $slug = get_term_parents_list($terms[0], 'tsrc_public_category', ['format'=>'slug','link'=>false]); return str_replace( '%tsrc_public_category%/' , $slug , $post_link ); } } return $post_link; });
All works well with this setup, except for the sitemap. It still shows my cpt products with links like
prod/%tsrc_public_category%/brown-old-pot/
Is there any way to fix this? A filter on TSF’s sitemap? An edit to my rewrite method from above?
I’m aware sitemaps could be overrated, but atm we’re doing a website revamp so re-indexing is of a high importance.
Any help would be greatly appreciated!
- The topic ‘Sitemap showing rewrite placeholder instead of category for cpt’ is closed to new replies.