All-in-One Event Calendar custom template code php

I recently used All-in-One Event Calendar on a WordPress site. It’s a very rich plugin with a lot of options. Tough there is a whole theme structure behind the plug-in, real customization is a little tricky. There is that possibility to use short-codes in posts, but when I wanted to use these in WordPress templates, I got stuck. For starters there’s almost no documentation (that I know of) on functions and or queries to use for custom pages. Thus leaving me no other option that to go through the plugin code myself and figure out what to do.

Now, if you are in the same situation, I’dd like to share with you what I did.

What I want is the following: A page based on a template, displaying two sets of events both in a different event category.

All-in-One Event Calendar events are stored in WordPress as normal posts with the post-type set to ‘ai1ec_event’. For the categories it uses taxonomies. At first this looks simple enough by doing a query on the post type including (or excluding) the categories. But a bug in Worpress prevents me from doing that. The categories are ignored, because of that bug. It’s two years old and they just closed the topic and moved on without fixing it. /Sadface.

ok, now for the solution.

To get around this, I decided to take a OO approach using the events object. I did this by using the code I found here:
Then, to display the event’s I used a foreach loop (something like this):

To get the categories working, I used the $filter option. I changed it to:

You find the categorie number if you hover above the categorie (in the post or in the editor).

If you want to display other fields of the event, you can access them in the event object. There is no map of the object, but I did a var_dump for you.

Note that some of the properties are part of the object “post”, which is in it’s part a property in the object $event, so to access them you need to use: $event->post->…

You’ll notice the $event->start is a timestamp, so you need to convert it. Use date() for this. Like so:

If you want it in your langueage, convert it using strftime() by using the locale settings. Like so:

That’s about it. Have fun.
Post questions or remarks in the comment section below.

2 thoughts on “All-in-One Event Calendar custom template code php

  1. suresh

    i tried above code.
    global $ai1ec_events_helper, $ai1ec_calendar_helper;
    but $ai1ec_events_helper return null

Leave a Reply

Your email address will not be published.