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

  • SEARCH
  • Home
  • 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 610679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:42:05+00:00 2026-05-13T17:42:05+00:00

Working in WordPress here. As you may know, all of the typical solutions for

  • 0

Working in WordPress here. As you may know, all of the typical solutions for displaying upcoming events in WordPress are awful, so I’m accomplishing it with simple custom fields. Each event the user will enter they will enter a Numeric date “YYYYMMDD”.

What I need to find out is how to code in PHP for the script to first get php:the_date <‘YYYYMMDD’> and then have WordPress filter events dynamically, only displaying posts that have a value greater than or equal to the numeric value printed (which would be the YYYYMMDD format of “today” which is pulled in via PHP:the_date.

Here is the wp_query I’m using:

    <?php
        $recentPosts = new WP_Query();
        $recentPosts->query('showposts=5&meta_key=event_date&orderby=meta_value&category_name=events&order=ASC');       
    if ($recentPosts->have_posts()) : while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
  • 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-13T17:42:05+00:00Added an answer on May 13, 2026 at 5:42 pm

    To get the date: $current_date = date('Ymd')

    You should then be able to query your posts something like this:

    $recentPosts = new WP_Query();
    $recentPosts->query(array(
        'category_name' => 'events',
        'meta_key' => 'event_date',
        'meta_compare' => '>=',
        'meta_value' => $current_date,
        'orderby' => 'meta_value',
        'order' => 'ASC',
        'posts_per_page' => 5
    ));
    

    Then you can loop through the posts as normal. If you need to do pagination it will be a bit more complex, see to the documentation for query_posts.

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

Sidebar

Related Questions

I'm working with wordpress.com along with the custom design upgrade to be able to
I'm working on WordPress theme which has some custom functionality which includes the ability
i'm having a little problem. I'm working on a wordpress template which lists all
So I have been working with Wordpress 3.x and trying to build a custom
So, I'm working on a WordPress theme that uses a custom taxonomy to create
I am working on a custom plugin in wordpress. I have a weird issue
I have read all over the place how WordPress is only capable of working
I'm working on my own custom WordPress theme, using a blank, default template to
I've installed Wordpress here http://www.trsmithroofing.co.uk/flat_roof_blog and I've noticed that URL re-writes are working nicely.
I am working on wordpress and I have to add a metabox in case

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.