In my WordPress project, I have several different custom post types
and they all share a common taxonomy. I am in the final stage of the project and now is time to link all custom post types using a sidebar widget. The problem I am having is that I don’t know the appropriate way to get the term link
linked to the correct custom post type.
For example, I have custom post types: book, author, product; and a taxonomy: genre that includes a horror category.
I would like to be able to get link structure as such:
/book/genre/horror
/product/genre/horror
/author/genre/horror
When I do get_term_link('horror');
, I get one of the term links, it seems that one of the custom post type has preference. How can I manage to get each term link corresponding to the correct custom post type?
Hard coding it is never a good idea, so I was wondering if there is a proper way to go about this. This is an old issue I am having, and have done a lot of searching for a solution but I didn’t find it. I come here as the last resort. Thanks.