0

The query_posts totally ignores the day argument. I'm trying this:

$day = date('j');
query_posts('day='.$day);

if (have_posts()):
   while (have_posts()): the_post();
   //show posts
   endwhile;
   wp_reset_query();
endif;

What I'm doing wrong?

  • Never use query_posts, instead use WP_Query or get_posts – Tom J Nowell Sep 27 '13 at 21:00
  • I want to use the date parameter, for example: query_posts('date='$date); If I understand correctly, I cannot use it with WP_Query, or can I? – jay Sep 27 '13 at 21:02
  • query_posts is a wrapper around WP_Query that does horrible things to the main query loop, never use it under any circumstances – Tom J Nowell Sep 27 '13 at 22:30
0

Don't use query_posts this will alter your main loop, you can query posts by day 1-31 using WP-Query();

$day = date('j');
$args = array( 'day' => $day);
$day_query = new WP_Query($args);

if ($day_query->have_posts()) :
   while ($day_query->have_posts()) :
       $day_query->the_post();
       //show posts
   endwhile;
   wp_reset_postdata();
endif;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.