Iâm having a page which displays all custom taxonomy terms for a particular type which I get from the URL. I use this code to retrieve all the terms:
$args = array(
'post_type' => 'mycustomposttype',
'programtype' => âmy-custom-taxonomy-term
);
$programtype = new WP_Query($args);
while ( $programtype->have_posts() ) : $programtype->the_post();
$terms = get_the_terms( $post->ID, 'my-custom-taxonomy );
This all works perfectly fine but then I want to produce a link, when pressing on each of the terms to redirect back to the original custom post it belongs to.
Let me give an example:
The custom post type âProgramblockâ with ID 19, has three custom taxonomy terms attached to it, which is called âeventsâ. The three terms is listed on above mentioned page, but then I want to produce a link which takes them back to the custom post type page âProgramblockâ with the post ID as hashtag, like this:
http://www.my-domain.com/programblock#19
How can I reverse this so Instead of asking âWhich terms does this post hasâ I want to ask, âWhich post does this term belongs toâ.
I hope Iâve explained myself clear enough, otherwise please ask.
Sincere
– Mestika
You could do it using the term_link filter.
Something roughly as follows: