• Hi all,

    I’m pulling my hair to work this one out, mind you I’m fairly new with WordPress and server side scripting.
    So, what I’m trying to achieve is to pull out 15 random posts from the last 6 months; I think this is possible, no?
    I’m using WP_Query as I’m running a second loop, outside the main one.

    Thanks in advance for any input.

Viewing 1 replies (of 1 total)
  • Thread Starter wieloh

    (@wieloh)

    Oh, alternatively, I found this:

    $args = array( ‘numberposts’ => 15, ‘orderby’ => ‘rand’ );
    $rand_posts = get_posts( $args );
    $postid = array();
    foreach( $rand_posts as $post ) :
    array_push($postid,get_the_ID());
    endforeach;

    Where I can conveniently pull out 15 random post ID and get them into an array for later use when I want to pull out the posts content; but how would I go in constraining those 15 ID into only for posts over the last 6 months?

Viewing 1 replies (of 1 total)
  • The topic ‘Showing random post over time period’ is closed to new replies.