• Hi,

    I’m looking for a way in a custom query to fetch 5 random posts among the last 15 posts in one given category. Is there a way to do this?

    Right now this is what I’ve got:

    <?php global $post;
    	$args = array(
            'orderby' => 'rand',
    	'numberposts' => 5,
    	'category' => 5
    	);
    	$myposts = get_posts( $args );
    	foreach( $myposts as $post ) : setup_postdata($post); ?>

    Which gives me 5 random posts that are in category 5, but with no limit back in time/posts numbers.

    Thanks!

  • The topic ‘random posts in one category 15 posts back’ is closed to new replies.