Добавляем в нужное место код
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?php $max = 5; //number of categories to display $taxonomy = 'product_cat'; $terms = get_terms('taxonomy='.$taxonomy.'&orderby=name&order=ASC&hide_empty=0'); // 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); }); // Echo random terms sorted alphabetically if ($terms) { foreach($terms as $term) { echo '<p><a href="' .get_term_link( $term, $taxonomy ) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a></p> '; } } |