Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

reto.kuepfer on "query custom post type by date"

$
0
0

Hi
I created a custom post type envent.
I d like to filter out post in the futere.
I did use the advanced custom fields plugin to make a date picker.
I used following code, but somehow id does not filter out the future post.
I'm thanksful for any sugestions.

<?php $events = new WP_Query(
     			array(
     	'post_not_in'    => array($donotrepeat),
        'post_type'       => 'chuchi_event',
     				'meta_key'        => 'event_datum',
     				'orderby'        => 'meta_value',
     				'order'           => 'dsc',
            'meta_query'  => array(
                  'key'     => 'event_datum',
                  'value'   => date("Ymd"),
                  'compare' => '<=',
                  'type'    => 'DATE'
                )
     		)); ?>

        <?php while($events->have_posts()) : $events->the_post(); ?>

                <?php $date = date_create(''.get_field('event_datum').''); ?>
                <p><?php echo date_format($date,'l d.m.Y'); ?></p>
                <a>" title="<?php the_title_attribute();
            	?>" >	

            <?php endif; ?></a>

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]


Viewing all articles
Browse latest Browse all 8245

Trending Articles