Adding active/current class to get_terms list

Run a conditional check in the foreach loop using is_category($term-name) Assign a class variable to active if it’s the same as $term->name $terms = get_terms( ‘category’ ); echo ‘<ul>’; foreach ( $terms as $term ) { $class = ( is_category( $term->name ) ) ? ‘active’ : ”; // assign this class if we’re on the … Read more

Show all wp_get_post_terms slugs

This is more of a PHP question, but the solution is simple – you need to use a foreach-loop on $getslug, because you just echo the slug of the first taxonomy. The function wp_get_post_terms() does not return a single object, but an array of objects. You are right with the [0], this indicates that you … Read more

How to filter the taxonomy terms based on another taxonomy term

I did few tweaks on the earlier code, the first filter is working fine for now, I am little confused on the rest any suggestion sven ? can you help me to bring this effectively. <!– last edit started by dev –> <script type=”text/javascript”> function onchangedestination(str) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, … Read more

Outputting an array of term meta values in a custom WooCommerce tab?

For your author content display, instead of print_r($all_term_meta); try a foreach: foreach($all_term_meta as $meta) { return $meta[0]; } It’s possible you may need to use “echo” instead of “return” but try “return” first. To control whether or not there is an author tab, update your woo_new_product_tab function with the same condition: function woo_new_product_tab( $tabs ) … Read more