Skip Navigation

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

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.

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 8 years, 10 months ago.

Assigned support staff: 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

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

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

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

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.