Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.