Tell us what you are trying to do?
I'm trying to show the category after the custom post type in the URL.. I have 2019 as a category.. so hidden link .... I want this to be hidden link
Is there any documentation that you are following? No
Is there a similar example that we can see? No
What is the link to your site? hidden link
Hi Ryan,
Thank you for contacting us and I'd be happy to assist.
This will require adding custom rewrite rule and then filtering that post type's URL, as explained in this reply:
https://wordpress.stackexchange.com/a/94820
For example, suppose that you have a custom post type with slug "book" and the slug of the custom taxonomy that you'd like to include the term from is "book-type-slug".
In your custom post type's edit screen, you can select "Use a custom URL format" option with the text "book/book-type"
Screenshot: hidden link
And in your theme's "functions.php" file, you can include the custom filter to replace the static "book-type" part with the first attached term's slug:
function wpa_course_post_link( $post_link, $id = 0 ){
$post = get_post($id);
if ( (is_object( $post )) && ( $post->post_type == 'book' ) ){
$terms = wp_get_object_terms( $post->ID, 'book-type-slug' );
if ( ! empty( $terms ) ) {
if ( ! is_wp_error( $terms ) ) {
return str_replace( 'book-type' , $terms[0]->slug , $post_link );
}
}
}
return $post_link;
}
add_filter( 'post_type_link', 'wpa_course_post_link', 1, 3 );
I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
regards,
Waqar