Skip to content

Instantly share code, notes, and snippets.

@thefrosty
Created May 5, 2012 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thefrosty/2604443 to your computer and use it in GitHub Desktop.
Save thefrosty/2604443 to your computer and use it in GitHub Desktop.
Custom query to grab posts from the same day..
global $post;
$args = array(
'post__not_in' => array( $post->ID ),
'posts_per_page'=> -1,
'day' => get_the_time( 'd', $post->ID ),
'month' => get_the_time( 'm', $post->ID ),
'year' => get_the_time( 'Y', $post->ID ),
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
endwhile;
endif;
// Reset Post Data
wp_reset_postdata();
// Reset Query
wp_reset_query();
@thefrosty
Copy link
Author

This query is grabbing posts from each day. When I want it to just query the posts from the posts date.

@colinloretz
Copy link

I believe 'month' has to be 'monthnum'

http://codex.wordpress.org/Class_Reference/WP_Query under Time Parameters

@thefrosty
Copy link
Author

Ah crap, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment