Skip Navigation

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

This support ticket is created vor 10 Jahre. 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 Antworten, has 2 Stimmen.

Last updated by Luo Yang vor 10 Jahre.

Assigned support staff: Luo Yang.

Author
Artikel
#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: Englisch (English ) Vereinfachtes Chinesisch (简体中文 )

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: Englisch (English ) Vereinfachtes Chinesisch (简体中文 )

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

Das Thema „[Geschlossen] In a taxonomy-archive loop, how do I get the current taxonomy?“ ist für neue Antworten geschlossen.