Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3345382
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:10:45+00:00 2026-05-18T01:10:45+00:00

Hi so I have a custom loop that is supposed to show upcoming events

  • 0

Hi so I have a custom loop that is supposed to show upcoming events only it’s not taking into account the year so it’s displaying future events as being in the past due to just the month and date.

<ul class="upcoming">
<?php // Get today's date in the right format
$todaysDate = date('m/d/y H:i:s');
?>

<?php query_posts('showposts=2&cat=9&meta_key=Date&meta_compare=>=&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC'); ?>

<?php if (have_posts()) : ?>
<?php while (have_posts()) : ?>  
<?php the_post(); ?>

<li>
    <?php 
    $Date = get_post_meta($post->ID, 'Date', true);
    ?>

        <?php if ($Date) : ?>
        <div class="date"><span class="month"> <?php echo date('M',strtotime($Date));?> </span>
            <span class="day"><?php echo date('j',strtotime($Date));?> </span></div>
        <?php endif; ?>
        <h4 class="EventTitle"><a href="<?php the_permalink(); ?>" title="Permanent link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4>
        <span class="EventType"><?php
                    foreach((get_the_category()) as $childcat) {
                    $category_link = get_category_link( 
                                            $childcat );
                    if (cat_is_ancestor_of(10, $childcat)) {
                    if (in_category('13'))
                    echo "<a href=\"$category_link\">Workshop</a>";
                    else echo "<a href=\"$category_link\">$childcat->cat_name</a>";
                    }}
                    ?>
        </span>
            </li>

<?php endwhile; ?>
<?php else : ?>
    <p>Check back soon for new events.</p>
<?php endif; ?>                 
<?php wp_reset_query(); ?>

The ouput for this module is “Check back soon for new events”, regardless of the fact that there are future events available.

I’ve scoured this thing for hours and can’t come up with a reason for why it’s ignoring the year. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:10:46+00:00Added an answer on May 18, 2026 at 1:10 am

    It would seem to me that you are comparing the date as a string rather than as a date literal. And because you are comparing strings, and have it set as mm/dd/yyyy, the month and date take a greater precedence than the year does. So 10/21/2014 is less than 10/22/2010.

    You may have to reformat your post_meta Date format to be able to make an accurate date comparison. The best way would be to use yyyy-mm-dd hh:mm:ss so everything is in order of decreasing precedence. Alternately, you could break apart the post_meta Date and compare the year then month then day and time in that order.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom read-only data structure that I need to transverse. I would
I have custom classes that I currently instantiate within App.xaml as resources. I want
I have custom event that has several different subscribers who will all use the
I have custom gallery. Gallery represents items that are frame layout. There are one
I have custom component that I can place in my layout file (XML) for
I have a custom control that I use that has some (NSTextField *) NSCells
Does anyone know or have good links that explain what iPhone's event loop does
hey guys, we have a loop that: 1.Loops over several thousand xml files. Altogether
HI have a custom view class that is loaded and placed within my main
I have a workflow inside a Windows Service that is a loop that performs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.