I am working on a client site and the statement I wrote 6 months ago seems to have stopped working after the WordPress update to 3.8 I can't see or figure out why.

There are no errors appearing it just returns empty divs with post Id's in the class field. If the the if statement is false then it needs to echo out different data. But sadly it isn't it still spits out the the first H3 tag.

<div class="span4">
    <?php // Blog post query
    $today = date('Y-m-d');

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $currentID = get_the_ID();
       'post' => 'ID', 
       'post_type' => 'foodswaps', 
       'posts_per_page' => 3, 
       'meta_key' => '00.event-date',
       'meta_value' => $today,
       'meta_compare' => '>=',
       'orderby' => 'meta_value',
       'order' => 'ASC' 

    if (have_posts()) : ?>
    <h3 class="calendar">Upcoming Swaps</h3>
    <?php while (have_posts()) : the_post(); ?>
        <div <?php post_class('clear-spacer no-margin'); ?>>                                    
                $field_name = "00.event-date";
                $listEventDate = get_post_meta($post->ID, $field_name, true);
                if (($listEventDate == 'E.g. yyyy-mm-dd') && ($listEventDate == '')) { ?>

                <a href="<?php the_permalink(); ?>" title="<?php  the_title_attribute( 'echo=0' ); ?>">
                    <h4><?php the_title();?></h4>
                    $converted = date('Y-m-d', strtotime($listEventDate));
                    $reversedDate = date('jS F Y', strtotime($converted));

                    echo $reversedDate;?>
                <?php  } ?>
        </div><!-- /.post_class -->
    <?php // end of blog post loop.
    endwhile; wp_reset_query(); // end of the loop and reset the query. 
        echo '<h3 class="theblog">Our Social Networks</h3>';
        echo '<p>Why not visit us on our social networks?</p>';


1 Answer 1


I can't see a problem with your if-else-statement, so I'm thinking the problem origins somewhere else. You say you get no errors, I guess you have debugging enabled. Besides, did you debug and inspect - var_dump or print_r it - the $wp_query object, to see if it is really empty, has no posts.

Another thing, you are using query_posts(), which you shouldn't. I don't want to replicate the argument for that, so see those two questions for more information:

This should clear now, better use pre_get_posts or WP_Query or get_posts.

One more remark, you are using:

  • 'post' => 'ID'

in your arguments array, but post isn't a valid parameter - see this question for more information.

  • Yes there is definitely data there. if the I change != to == it spits out the data I expect to see. I will rebuild the query to see if that helps.
    – DLaverick
    Apr 8, 2014 at 12:15
  • 1
    Ok, not sure if I totally grab your sentence, but I would say, definitely rebuild your query and if the problem remains come back with the new information. @DLaverick Apr 8, 2014 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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