How do I access a single term from a post?

It’s a little bit hard to be sure, what are you asking exactly, but… Let me try to answer… So somewhere in single.php you’re getting terms for current post using this code: $terms = wp_get_post_terms($post->ID, ‘mytax’, array(“fields” => “all”)); and you want to get the ID of first term from that list? If so, you … Read more

Formating the_terms() function output

While you can specify separators and such in the_terms() arguments, it assumes that you actually want links. You can discard unwanted HTML by using filter: add_filter(‘the_terms’, ‘no_terms_links’, 10, 2); function no_terms_links($term_list, $taxonomy) { if (‘type’ == $taxonomy) return wp_filter_nohtml_kses($term_list); return $term_list; } Or just use deeper get_the_terms() function and iterate through its return to build … Read more

How to order the get_categories result

Firstly, $product->get_categories() won’t work because it’s a woocommerce function, that basically is just a wrapper for get_the_term_list, which has no sorting parameter. It’s always good to take a look at the source to know what you’re dealing with. Secondly,get_the_term_list uses get_the_terms, but it also has no sorting parameter. The latter get the terms either from … Read more

Get terms from multiple taxonomies

If you want to retrieve multiple taxonomies you need to put the four taxonomies in an array, you are doing this, but you have put taxonomy=> in the array. $terms = get_terms( ‘taxonomy’ => array( ‘vehicle_safely_features’, ‘vehicle_exterior_features’, ‘vehicle_interior_features’, ‘vehicle_extras’) ); Hope it helps

Why is my WP_Query not working when tax_query terms are an array?

When you’re doing a tax_query or meta_query in a WP_Query, you always have to use a nested array( array() ); just see the following example for an explanation and pay attention to the relation argument. $packages = new WP_Query( array( ‘post_type’ => ‘vamos-cpt-packages’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘vamos-holiday-types’, ‘field’ => … Read more