Skip Navigation

[Closed] In a taxonomy-archive loop, how do I get the current taxonomy?

This support ticket is created 11 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 11 years ago.

Assisted by: Luo Yang.

Author
Posts
#24891

ido

In a taxonomy-archive loop, how do I get the current taxonomy ?
I thought this should work : [wpv-taxonomy-slug]
But this field is empty for some reason.

example usage :
[mashup show="query" show_query="book=[wpv-taxonomy-slug]&posts_per_page=-1" poilist="true" ]

#24949

Hi ido,

You can use Views shortcode [wpv-post-taxonomy] Display the taxonomy for the current post, like this:
[wpv-post-taxonomy type="my-taxonomy" separator=", " format="link" show="name"]

More help: https://toolset.com/documentation/views-shortcodes/#wpv-post-taxonomy

If you need display current taxonomy in a WP loops, you can try create a shortcode for it.
Regards
Luo

#24971

ido

How do I create a shortcode for it in WP loops ?

#25238

You can try create a shortcode for it, like this:
1) put codes in your theme/functions.php
add_shortcode('current_taxonomy_slug', 'current_taxonomy_slug_func');
function current_taxonomy_slug_func(){
$term = get_queried_object();
$slug = $term->slug;
return $slug;
}
2) put the shortcode into your content
[current_taxonomy_slug]

More help: http://codex.wordpress.org/Function_Reference/get_queried_object

The topic ‘[Closed] In a taxonomy-archive loop, how do I get the current taxonomy?’ is closed to new replies.