WordPress.org

Ready to get started?Download WordPress

Forums

How to get 5 random tags out of all 70 tags (6 posts)

  1. Pete
    Member
    Posted 2 years ago #

    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

  2. Pete
    Member
    Posted 2 years ago #

    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?

  3. jnhghy
    Member
    Posted 2 years ago #

    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

  4. Pete
    Member
    Posted 2 years ago #

    Thanks, but nope :) It's driving me wild the random feature just won't work for me.

  5. jnhghy
    Member
    Posted 2 years ago #

    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.

  6. Pete
    Member
    Posted 2 years ago #

    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 :)

Topic Closed

This topic has been closed to new replies.

About this Topic