Showing post according to post dates

i have one event plug-in and now i want to show my event post like current events,upcoming events then past events.i have created one custom post for this and create 2 meta-boxes for start date and end date. But now how i call?


Without more details, I just can say you'll probably need to perform a query similar to this one:

$args = array(
    'post_type'      => 'events',
    'posts_per_page' => -1,
    'order'          => 'ASC',
    'orderby'        => 'meta_value_num',
    'meta_key'       => 'end_date',

    'meta_query'     => array(
            'key'      => 'endt_date',
            'value'    => time(),
            'type'     => 'numeric',
            'compare'  => '<'

$past_events = new WP_Query( $args );

This would return the past events, assuming your post type is called events, you have a custom field end_date that stores a numeric timestamp...

You should modify the meta_query accordingly for current and past events, using different value and compare arguments.

Take a look at docs for WP_Query class and in particular to the Custom Field Parameters section.

Similar questions

How to only keep posts with dates in between other dates?
I have some posts with some custom fields where I have a date in a string format, so I loop my posts and I convert each of them as a Date, then I do some bit to have them in order by date: So I am attaching the date together with the ids and that gives us: OK now what we do is GET some $start and $end dates from a form using GET And that gives us: ...
How to set auctions according to their dates and current status?
We want to set auctions according to their current status means currently running auctions should be shown in current auctions and future auctions will be categorised in upcoming auction category and outdated auctions should move to past auctions automatically, we dont need to categories them manually.
Show wordpress daily posts according to timestamp custom dates
i can't figure out how to list daily posts according to date when the date is saved as timestamp in DB. So i have got a code like: The meta_value is pasted from one certain post, but, how to show all posts from the day by timestamp? Somebody was on to this maybe?
No disabled dates in datepicker using php array of dates
I'm trying to take dates from a date field in a custom post type in wordpress and then transfer the dates into an array. Then that array is converted to a js object. That js object is used in a datepicker with beforeShowDay, but it is not working. I get the datepicker but no dates are unavaible. If I do: in the php part i get: Array ( [0] => 202...
dates under post titles -- also showing up under Nav
I added a filter in functions.php in order to have the dates show up under my titles on each Post on my homepage. Random dates are now also showing up in the Nav. Can someone help me make those go away? I'm happy they show on the posts now, so I did something right! But the dates in the Nav have got to go! I'm developing the site here: internalcomp...
Comments and post dates not showing up correctly on "posts page"
I have customized the Twenty Fourteen theme to use the page "news" for my posts page because I have static frontpage. When you view my news page, comments don't show up, even though they are enabled, and when you go to the specific post, they are. Is there any way to add the comments to the news page, where the posts are supposed to show up in full...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.