Display a list of random terms from custom taxonomy with shortcode

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

ACF – Retrieve custom taxonomy from a relationship field

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

taxonomy query to output slugs instead IDs

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