• Hi

    I use the next code for show my post

    <?php $my_query = new WP_Query('cat=9&showposts=10'); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?>
    <?php the_title(); ?>
    <?php the_content(); ?>
    <?php the_excerpt(''); ?>
    <?php endwhile; ?>

    Show the items of the category 9 in order for date.
    How can show the post in random order?

    thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter euforico

    (@euforico)

    Both plugins working, but isn`t what i need because:

    Random post plugin and post options: working only for one function, i can call only a one random post and i need five similar random post

    Do you know about another plugin? or give a random order with my function?

    hola euforico,
    to show any random posts from a single category you should specify this string to the “query_post” function (instead of using “wp_query”):

    // show me 10 random posts from category ID=9
    
    <?php $my_query = new query_posts("cat=9&showposts=10&orderby=rand"); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?>
    <?php the_title(); ?>
    <?php the_content(); ?>
    <?php the_excerpt(''); ?>
    <?php endwhile; ?>
    
    // show me 12 random posts from categories ID's 1,2,3
    
    <?php $my_query = new query_posts("cat=1,2,3&showposts=12&orderby=rand"); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?>
    <?php the_title(); ?>
    <?php the_content(); ?>
    <?php the_excerpt(''); ?>
    <?php endwhile; ?>

    I also recommend you to pass by Anieto2K’s blog, he has interesting stuff about controlling this function.

    just worked for me! so glad i’ve found this other post with the missing parameter.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show post in random order’ is closed to new replies.