WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can i get movies there are today in cinema, for example my code display the movies in time that shoud apear 16 January,17 January..., how can i display only the movies in this day.

Ex: today is Wensday 16 January 2013, how can i get only the posts(movies) that shoud apear only today

If i have 2 movies that premiere is on 16 i want to display only that.

For the meta key i use a custom field -'meta_key' => 'premiera_cinema' - with this i select the day.

   <?php // Get today's date in the right format
    $todaysDate = date('Ymd');

<?php $loop = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => 3,
'meta_key' => 'premiera_cinema',
'meta_compare' => '>=',
'meta_value' => $todaysDate,
'orderby' => 'meta_value',
'order' => 'ASC'
) ); ?>

<?php while ($loop->have_posts()) : $loop->the_post(); ?>
share|improve this question
Where are you defining $todaysDate? – Alex Lane Jan 16 '13 at 20:58
please look now – Batman Jan 16 '13 at 21:15
What is the date format of premiera_cinema? Show the field configuration... What does this query outputs? – brasofilo Jan 16 '13 at 23:19
up vote 1 down vote accepted

This will compare today's date to the date meta key and select posts with a dates that are greater than or equal:

'meta_compare' => '>='

If you want to match only today's date, change it to just equal:

'meta_compare' => '='
share|improve this answer
thanks milo, i undestand now – Batman Jan 19 '13 at 21:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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