Srilatha Marru's Blog
WordPress Events Manager – Get the ical file per category

I am using the wordpress plugin Events Manager http://wp-events-plugin.com/ It had features to download the ical files for an individual event and all the events on the site. Both of these can be achieved with below urls:

http://example.com/events.ics – This url gets the ical file with all the events on the site.
http://example.com/event//ical – This gets an ical for an individual event.

And I want to get the ical file per category.

To get the ical file per category below are the steps to follow:

  1. Modify the ical template templates/ical.php and add a search attribute e.g. ‘category’=>’7′

    http://wp-events-plugin.com/documentation/using-template-files/

    http://wp-events-plugin.com/documentation/event-search-attributes/

  2. To get the category ID I used the following code:

    $uri=$_SERVER['REQUEST_URI'];
    $args=explode('/',$uri);

    /* Get the category ID */
    if($args[1]=='events' && $args[2]=='categories') { $cat_name=$args[3]; $cat_obj=get_term_by('name', $cat_name , 'event-categories'); $cat_id=$cat_obj->term_id; }

  3. The url for the ical file per category will be http://example.com/events/categories//events.ics

I hope this will save some time for you!



AUTHOR

profileWeb Developer working in advertising agency.

Recent tweets

The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.