Get main parent category for post (WordPress/Advanced Custom Fields)
Get main parent category for post (WordPress/Advanced Custom Fields)
Get main parent category for post (WordPress/Advanced Custom Fields)
Try this code: function these_rand_tax1() { $max = 8; //number of categories to display $taxonomy = ‘baumaschinen_cat’; $terms = get_terms(‘taxonomy=’ . $taxonomy . ‘&orderby=name&order=ASC&hide_empty=0’); $terms = (array)$terms; // Random order shuffle($terms); // Get first $max items $terms = array_slice($terms, 0, $max); // Sort by name usort($terms, function ($a, $b) { return strcasecmp($a->name, $b->name); }); // … Read more
Prioritise Pages over Taxonomy Term Root Archive, but not Taxonomy Term Child Archives
get terms hiding empty
How to get related taxonomies based on a category with mysql query?
I managed to solve my issue by looping through a get_the_terms() function. In my case, I’ve also created a shortcode. function display_taxonomy() { $prognoses = get_field(‘prognosis’); ob_start(); if( $prognoses ): foreach( $prognoses as $prognosis ): $terms = get_the_terms( $prognosis->ID , ‘my_custom_taxonomy’ ); foreach ( $terms as $term ): echo $term->name; endforeach; endforeach; endif; return ob_get_clean(); … Read more
Exclude taxonomy term from list of current taxonomy terms
The terms for the tax_query should be an array.
Nothing stands out as ‘wrong’ – though you do have a few errors: The third tax_query conditional is missing a closing bracket The third tax_query should be querying precio not $ubicacion. Cast the ID variables as integers I’d suggest putting WordPress into debug mode to highlight any syntax errors. Try doing it for only one … Read more
setup_postdata will let you use loop functions with post results via get_posts. another option is to use the various filters available to alter WP_Query‘s behavior- posts_join, posts_where, posts_orderby.