New answers tagged

1

For reliability, you can get the current term being viewed from the queried object from $GLOBALS['wp_the_query'] $current_term = sanitize_term( $GLOBALS['wp_the_query']->get_queried_object() ); To answer your question, if Southern Africa is top level, it should have a parent term ID of 0. All child terms should have a numeric value as parent which ...


0

You can easily just get the taxonomies you need with wp_get_object_terms, and than do something like $class =''; foreach ($genres as $genre) { $class .= $genre->slug; } Do this for each of your taxonomies,than just echo $class.


2

Samuel Elh correctly answered this. if ( $type === 'portfolio' ) { $terms = get_the_term_list( $post->ID, 'royal_portfolio_cats', '', $separator ); $term_array = explode(',',$terms); if ( $limit = array_slice($term_array, 0, $max = 5) ) { echo implode( ", ", $limit ); if ( count( ...


2

You just need to get the term id's of the terms assigned to a post, and then exclude those terms from get_terms() You can try the following (Just note, the syntax for get_terms() changed in v4.5, I'll be using the new syntax) $args = []; $taxonomy = 'my_tax'; $post_terms = get_the_terms( get_the_ID(), $taxonomy ); // Use wp_get_post_terms() if you ...


0

With the get_term_children() function there is nothing to pass which will hide empty terms. You could do that in your foreach as each term has a property which holds how many posts it is assigned: foreach( $style_categories as $style ) { $child = get_term_by( 'id', $style, 'product_cat' ); // Skip empty terms if( $child->count <= 0 ) { ...


0

'LIKE' isn't supported by the current version of WP_Tax_Query, so you'll need to write a custom query. This answer from a couple of years ago still seems to be the best approach: http://wordpress.stackexchange.com/a/133805/26317.


0

I was working on someone else WP installation so I can get the info of WP Database to show Products information in a side-page. I've noticed that they have a plugin installed (Taxonomy order) that always return the terms posts in the same orden. Sorry for the confusion!



Top 50 recent answers are included