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

Wrap template code with shortcodes

Using output buffering seems like the way to go in this case, ob_start() to start buffering, then ob_get_clean() to get and clean the buffering. <?php ob_start(); ?> <div class=”column”> <div class=”columns resource_downloads”> <?php if ( have_rows(‘_downloads_group’) ) : ?> <?php while( have_rows(‘_downloads_group’) ) : the_row(); ?> <div class=”column v-align-top”> <figure class=”download__img outer-1by1″> <img class=”inner-1by1″ src=”<?php … Read more