After a pretty exhaustive search, I'm stumped.
I have a Wordpress custom post type named: listings. Listings have taxonomies called Services and Areas.
The default structure is
/listing/%post-name%
I'm trying to achieve a structure that looks like:
/%services%/%areas%/%post-name%
I was able to achieve something close using the plugin Custom Post Type Permalinks which gives me this working URL:
/listings/%services%/%areas%/%post-name%
And then used the code
function gp_remove_cpt_slug( $post_link, $post, $leavename ) {
if ( 'listing' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
return $post_link;
}
add_filter( 'post_type_link', 'gp_remove_cpt_slug', 10, 3 );
That shows a permalink of what I want when I edit the listing but there's a 404 error when I go to that URL. I'm not sure where to go from here. Please help.