Support » Fixing WordPress » How to display random posts?

  • If been using this Mimbo theme, and in the index page it shows some posts using:

    $display_categories = array(5,19);
    foreach ($display_categories as $category) { ?>

    There you choose witch categories to display.

    I want to know if it’s possible to display random posts insted of fixed posts.

    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You might need to paste the complete contents of index.php in at and report the link back here.

    In the meantime,

    Or, via a magical 2 seconds with google, you could always go straight to the Random Posts plugin. 😉

    Alternately you could try The Randomizer Plugin.

    The Randomizer

    I need to display a random post from a particular category on a page not in the loop, is this possible?

    Can you point me in the right direction please

    The page is in the theme root and is basically a static (home)page with a latest posts item which works fine, what I need to do is have a random post appear from a particular category (i.e. a random testimonial exerpt)

    Thanks in advance

    check the wordpress docs, theres lots of ways to do it.

    You would need to edit your static page so have something like this…

    <?php $yourquery = new WP_Query();
    $yourquery->posts(‘cat=(whatever number category youre using)&order=RAND’);
    while($yourquery->have_posts()) : $yourquery->the_post(); setup_postdata($yourquery); ?>


    <?php endwhile; ?>

    Thank you for that

    I’m still a bit lost as I get an undefined call to function error.

    Fatal error: Call to undefined function: posts() in /home/sites/public_html/wp-content/themes/wpremix/tpl_Home1.php on line 29

    I’m using WP2.5.1, and have spent hours reading the docs but its a bit above me to be honest.

    I’d appreciate a simple fix but I’m sure its not that easy

    Thanks in advance

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to display random posts?’ is closed to new replies.