Display upcoming events from Sugar Event Calendar

Sugar Calendar, like most other event calendars, stores the event dates as metadata. To sort your results by the event date (meta_key is sc_event_date_time) use:

[display-posts post_type="event" orderby="meta_value_num" order="ASC"]

That will list every event starting with the oldest to newest.

If you want to list only upcoming events, we’ll need to do a meta query. This specific meta query requires PHP coding as it’s too complicated to implement directly in the shortcode.

This is a great use case for adding shortcut arguments. If post_type=”event”, add all the necessary query parameters.

[display-posts post_type="event']

This code snippet goes in a core functionality plugin or Code Snippets.

Filters used:

Published by Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributor to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.