Quantcast
Channel: User Michael - WordPress Development Stack Exchange
Viewing all articles
Browse latest Browse all 44

Answer by Michael for How to add a shortcode function that returns the taxonomy slug of the actual post within the loop

$
0
0

get_the_terms() will always return an array; but because you have only one 'project_category', you can simply use its first element:

add_shortcode( 'return_taxonomy_slug', 'my_shortcode_return_taxonomy_slug' );function my_shortcode_return_taxonomy_slug() {  $terms = get_the_terms( get_the_ID(), 'project_category');  return $terms[0]->slug;}

Viewing all articles
Browse latest Browse all 44

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>