WordPress.org

Ready to get started?Download WordPress

Forums

display a single random tag and a single random category (8 posts)

  1. Pete
    Member
    Posted 2 years ago #

    I'm looking for way to...
    1. display a single random tag, and
    2. display a single random category

    If I could stretch the friendship a bit more to by asking if you could give me two different options... a linked version and a no link version.

    This is definitely worth a beer!

    Thanks, Pete

  2. Pete
    Member
    Posted 2 years ago #

    I found out how to do the category

    <?php query_posts('showposts=1&orderby=rand'); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php foreach((get_the_category()) as $cat) {echo $cat->cat_name . ' ';} ?>
    <?php endwhile; else: ?><?php endif; ?>
  3. Pete
    Member
    Posted 2 years ago #

    I'm not sure why but this DOES NOT display a single random tag?

    <?php wp_tag_cloud('number=1&orderby=rand'); ?>

  4. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    http://codex.wordpress.org/Function_Reference/wp_tag_cloud

    order
    (string) (optional) Sort order.
    'ASC'
    'DESC'
    'RAND' tags are in a random order.

  5. Pete
    Member
    Posted 2 years ago #

    This is still giving me the same single tag

    <?php wp_tag_cloud('number=1&order=RAND'); ?>

  6. Pete
    Member
    Posted 2 years ago #

  7. Pete
    Member
    Posted 2 years ago #

    <?php wp_tag_cloud('number=1&order=RAND'); ?>

    Why won't this work for me? it doesn't display a random tag, it only displays the first tag???

  8. hotwebideas
    Member
    Posted 1 year ago #

    Hey, I just found this.

    @Pete: I added &orderby=name to my wp_tag_cloud(), so it would be <?php wp_tag_cloud('number=1&orderby=name&order=RAND'); ?>

    Bruce

Topic Closed

This topic has been closed to new replies.

About this Topic