• Resolved sofielyr

    (@sofielyr)


    Hi fellow wordpressers!

    I am trying to solve an issue with my featured category slideshow in wordpress. I want the featured to show five posts from the “featured” category (in the slideshow) in random order.

    This is the code that I have that displays five posts but always in the same order…

    <?php
    	$tmp_query = $wp_query;
    	query_posts('showposts=5&cat=' . get_cat_ID(dp_settings('featured')));	if (have_posts()) :
    	while (have_posts()) : the_post();
    	?>

    I want to add something that makes the five posts show in a totally random order…

    Hope you can help me!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter sofielyr

    (@sofielyr)

    Is there no-one who can help me with this? Please i beg you!!!

    Sure, try this..

    <?php
    	$tmp_query = $wp_query;
    	query_posts( array( 'orderby' => 'rand' , 'posts_per_page' => 5 , 'category__in' => array( get_cat_ID(dp_settings('featured') ) ) ) );
    	if (have_posts()) :
    	while (have_posts()) : the_post();
    ?>

    Thread Starter sofielyr

    (@sofielyr)

    Yey!! Thanks so much!! It worked wonderfully!

    You’re welcome.. 🙂

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

The topic ‘Display random posts from featured category slideshow’ is closed to new replies.