I have
custom post type -> resources
custom taxonomy -> resources_type
I want custom permalinks where category base will be appended at the end instead of front
For example: I add a new resource with title "First resource" and assign term as type1
What I get - http://example.com/resources/resources-type/type1/first-resource
What i want - http://example.com/resources/first-resource/resources-type/type1
I am using the following argument code in register post type :
'rewrite' => array("slug" => "/resources/resources-type/%resources_type%"),
And then using following code to replace the "%resources_type%" in above code
function wpa_course_post_link( $post_link, $id = 0 ){
$post = get_post($id);
if ( is_object( $post ) ){
$terms = wp_get_object_terms( $post->ID, 'resources_type' );
if( $terms ){
return str_replace( '%resources_type%' , $terms[0]->slug , $post_link );
}
}
return $post_link;
}
add_filter( 'post_type_link', 'wpa_course_post_link', 1, 3 );