Support » Fixing WordPress » display random the_tags

Viewing 2 replies - 1 through 2 (of 2 total)
  • referring to the last posted section of code in the above linked topic, try this variation:

    ...
    if ($posttags) {
    	shuffle($posttags);
    	foreach($posttags as $tag) {
    ...

    http://www.php.net/manual/en/function.shuffle.php

    or this – to show a random sub-section, but still in alphabetical order:

    <?php
    $posttags = get_the_tags();
    if ($posttags) {
    	$posttagkeys = array_rand($posttags,3);
    	foreach($posttagkeys as $key) {
    		echo '<a href="'.get_tag_link($posttags[$key]->term_id).'">' . $posttags[$key]->name.'</a> ';
    	}
    }
     ?>
    Thread Starter Pete

    (@perthmetro)

    great works well

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘display random the_tags’ is closed to new replies.