query custom meta by date
-
I have a query for pages that have the textdate custom meta. I want to show only 1 page title closest to the current date. I cant seem to get it to work. I read one of the posts in the support forum and still couldnt get it to work. Am I missing something?
<?php $args = array( 'post_type' => array( 'page' ), 'orderby' => 'meta_value', 'order' => 'DESC', 'meta_key' => '_cmb_test_textdate', 'meta_query' => array( array( 'key' => '_cmb_test_textdate', 'value' => date('Ymd'), 'compare' => '<=', ) ) ); $the_query = new WP_Query( $args ); ?> <?php if( $the_query->have_posts() ): ?> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php endwhile; ?> <?php endif; ?> <?php wp_reset_query(); ?>
- The topic ‘query custom meta by date’ is closed to new replies.