Retrieve Taxonomy slug(s)
-
Hello,
I’m attempting to create a hyperlink within a post template that uses a slug from a specific taxonomy (“venue”). This is how the hyperlink should look for each post…
https://my-site.com/venues/{taxonomy-slug}/
There is only one value for each “venue” taxonomy. The rest of the link is static, so all that needs to happen is have the “venue” slug added to the end of the post. Here’s the code I have so far…
<a href="<?php echo get_option('home'); ?>/venues/ <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'venue' ) ); $interestname = $term->name; echo $interestname; ?>"> Venue Name</a>
This is a single line of code, I’ve just used breaks to make it more readable and so scrolling isn’t necessary when reading it on this forum.
I know someone will be quick to point out that it’s probably a lot easier to use something else besides a taxonomy for this, I actually do need to and this is just a small part of the project. This has to be done with the taxonomy.
Any ideas or help is much appreciated. Thank you.
- The topic ‘Retrieve Taxonomy slug(s)’ is closed to new replies.