WordPress + Custom Plugin Development + Platform Integrations

Programmatically Controlling Events Calendar Pro

By:

Mark Biek

on 1/28/2019

If you’re not familiar with The Events Calendar Pro from Modern Tribe, it’s amazing and part of standard install when building a WordPress site.

Note: We’re not in business with Modern Tribe. We just think they make a great product.

One of the things that I see a lot of people asking about is how to programmatically control the events page.

The default behavior is that all published events appear on the calendar which brings up the question of what if you want to selectively control which events are visible.

It turns out to be pretty simple thanks to the pre_get_posts action.

All you need is a little bit of code in you functions.php.

Let’s break down the above.

The first two if statements ensure that we’re only modifying the query when displaying the Events calendar.

For this example, we’re saying that we have an event category called Hidden

2019-01-22-at-2.29.04-PM-300x115.png

We modify the query to only display events that are NOT IN the Hidden category.

It’d be just as easy to only display events that do belong to a certain category (or multiple categories).

From there, the sky’s the limit. It’s that simple!

Share to

Related Posts

Custom Dev
Dynamic Select Fields with Advanced Custom Fields
Dynamic Select Fields with Advanced Custom Fields

By:Nick Stewart on 12/8/2021

In Advanced Custom Fields, there is the Post Object field that allows you to select a post resource from your WordPress website. This field can return the actual post object or the post ID.

Read More »
WordPress REST API: Secure ajax calls custom endpoints

By: Mark Biek on 5/9/2017

Here’s a handy guide to making secure ajax calls to custom REST endpoints. As you may have heard, the WordPress REST API is now included out-of-the-box as of WP 4.7.

Read More »