Show 1 post and after a specific date show the next one

I used the following query to have only 1 post published on the homepage from a particular category:

<?php if ( have_posts() ) : ?>
<?php query_posts('posts_per_page=1&orderby=date&order=DESC&cat=6'); ?> 

<?php while ( have_posts() ) : the_post(); ?>
   <?php wpe_excerpt('wpe_excerptlength_index', 'wpe_excerptmore'); ?>
<?php endwhile; endif; ?>

Each post has two custom fields containing a begin and an end date. What I need is that after the end date the next post (the one with following begin date) will be shown. But I don’t know how to do it.

Read More

Any hint?

Related posts

Leave a Reply

1 comment

  1. Assuming, as per the above comment, the format of the dates is YYYY/MM/DD:

    $args = array(
        'posts_per_page' => 1,
        'cat' => 6,
        'meta_key' => 'begin_date',        // adjust to actual key
        'meta_value' => date( 'Y/m/d' ),
        'meta_compare' => '>=',
        'order' => 'ASC',
        'orderby' => 'meta_value'
    );
    
    $wpse72195_query = new WP_Query( $args );
    
    // do something with the result