Reputation: 6856
I am new to WordPress development and have created a custom type of event
. I would now like to create a page which shows all upcoming events.
An event
has the following fields:
title
description
event_date
(type is CMB2's text_date_timestamp
)This works, and I have used manage_edit-{$post_type}_columns
to create an admin UI that allows for sorting by event_date
. So far so good. :-)
But now I want to map a URL like www.example.com/upcoming-events
to a page which shows:
event
s with an event_date
in the future.event_date
in ascending order.I need some help joining up a few dots ... I guess that I will need to use WP_Query
. But how do I map the URL path to a page with this WP_Query
?
Upvotes: 0
Views: 322
Reputation: 265
Just create page with slug upcoming-events
and place your custom shortcode (for instance, shortcode [upcoming_events]
) inside page's content.
Then add the shortcode definition inside your functions.php:
add_shortcode('upcoming_events',function() {
/* Use WP_Query and output the content you'd like to be displayed */
});
Upvotes: 1