Support » Fixing WordPress » How to get 5 random tags out of all 70 tags

  • I have about 70 tags, I want to get 5 different random tags out of that 70 each time the page refreshes… this isn’t working for me

    <?php wp_tag_cloud( array( 'taxonomy' => 'electrician-perth', format => 'list', order => 'rand', number => '5', smallest => '10', largest => '10') ); ?>

    All I get is the same 5 tags in alpha-numeric order each time I refresh my page?

    Thanks heaps,
    Pete

Viewing 5 replies - 1 through 5 (of 5 total)
  • OK I found out that if I change the ‘rand’ to ‘RAND’ it randomises the order of the list but I am still only getting the first 5 tags of the whole 40 tags, I want 5 different/random tags each refresh/reload?

    Hi, can you try:
    <?php wp_tag_cloud( array( 'taxonomy' => 'electrician-perth', format => 'list', orderby=>'RAND()' order => 'ASC', number => '5', smallest => '10', largest => '10') ); ?>
    this is untested but it should work from the mysql point of view.
    Regards

    Thanks, but nope 🙂 It’s driving me wild the random feature just won’t work for me.

    Check the mysql version this was a bug in an older version of mysql extra info here.Also there are more ways to make this possible check these examples 1 and 2 to randomize the results within mysql if none of them helps you then consider randomizing the results throw php.

    Check the mysql version
    5.1.63-community-log

    Also there are more ways to make this possible check these examples 1 and 2 to randomize the results within mysql if none of them helps you then consider randomizing the results throw php.

    Sorry I know even less about php than I know how to randomise tags 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to get 5 random tags out of all 70 tags’ is closed to new replies.