WordPress: Eine begrenzte Zufallsliste der Kategorien erzeugen

https://wordpress.org/support/topic/random-category-list

<?php
//display random sorted list of terms in a given taxonomy
$counter = 0;
$max = 5; //number of categories to display
$taxonomy = 'category';
$terms = get_terms($taxonomy);
shuffle ($terms);
//echo 'shuffled';
if ($terms) {
	foreach($terms as $term) {
		$counter++;
		if ($counter <= $max) {
	  	echo '<p><a href="' . get_category_link( $term->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'</a></p> ';
	 	}
	}
}
?>

Mehr zum Thema: WordPress · SEO · KI & Automatisierung

Mehr zu Website & SEO: SEO · WordPress · Domains · KI & Automatisierung

Website-, WordPress- oder SEO-Unterstützung gesucht? Wenn du bei Website, Domain, Hosting, Technik oder Sichtbarkeit professionelle Hilfe brauchst, findest du sie bei Krakovic IT.