• Resolved umesh.awasthi

    (@umeshawasthi)


    Hi all,

    I am just playing around with WordPress and neither I have any idea abt PHP. I am trying to fetch few random posts using get_posts() function of the WordPress my code is something like this

    <?php
        args1 = array( 'numberposts' => 12 ,'orderby' => 'rand');
        $rand_posts1 = get_posts( $args1);
                foreach( $rand_posts1 as $randpost1 ) : ?>
                    <?php the_title(); ?>
                         <?php endforeach; ?>

    But this code is only returning same post all the 12 times and that is the lastest post. I am clueless what exactly I am doing wrong.

    Can any one help me to correct my mistake or point me about my issue.

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WordPress get_posts() returning same post all the time’ is closed to new replies.