The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Query Multiple Taxonomies
Writing Multiple Taxonomies in Body Class? (2 posts)

  1. gumlor
    Posted 5 years ago #

    Is it possible to list multiple taxonomies, both the keys and the values, in the body tag class? Something like, for http://www.my-site.com/?genre=jazz&artist=bb-king :

    <body class="... tax_genre_jazz tax_artist_bb-king">

    I've tried the following code, but it ONLY works when there is a single taxonomy and it only show the key but not the value:

    function mysite_body_class( $classes ) {
    	if( is_tax() ) {
    		global $taxonomy;
    		if( !in_array( $taxonomy, $classes ) )
    			$classes[] = "taxonomy " . "taxonomy-".$taxonomy;
    	return $classes;

    Thanks a million for your help!

  2. scribu
    Plugin Author

    Posted 5 years ago #

    You can use qmt_get_terms() instead of the $taxonomy global.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Query Multiple Taxonomies
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic