WordPress.org

Support

Support » Plugins and Hacks » Hacks » [Resolved] Help with Random Posts via Category Not quite working!

[Resolved] Help with Random Posts via Category Not quite working!

  • MouseUK

    @mouseuk

    Hi,

    I’ll I’m trying to do is to get 6 random posts pulled out of the “feature” category at random and display their featured picture (little 100x100px) image in a box on the right side of my site.

    I have it mostly working if I remove “orderby=rand” it shows all 6 images in the right hand box of the latest 6 featured posts but I also want it to display older posts from the category hence trying to get it to randomise it.

    When I add the orderby=rand I get it randomly picking out older posts which is good but it also randomly displays between 1 and 6 posts instead of 6 random ones and I have no idea why.

    <?php query_posts('category_name=feature&showposts=6&orderby=rand'); ?>
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    Any ideas/help would be grateful.
    Thanks
    MouseUK

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael

    @alchymyth

    Forum Moderator

    it also randomly displays between 1 and 6 posts instead of 6 random ones

    do all of those ‘feature’ category posts have a featured image aka post thumbnail?

    MouseUK

    @mouseuk

    Yes, they all have a featured image.

    Michael

    @alchymyth

    Forum Moderator

    ideally, can you post a link to your site with the problem showing?

    does the ‘feature’ category have sub categories?

    what is the full code of your extra loop?

    MouseUK

    @mouseuk

    I’ve found it, you were right with your original post, I thought I had all the ones in the feature category set-up with an image.
    But thought I’d go through them all again to double check and 2 were missing 😀

    Sorted now, Thanks for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Help with Random Posts via Category Not quite working!’ is closed to new replies.
Skip to toolbar