at the moment, there isn’t any function in EM to exports feeds with only one category, you’d need to modify the ical templates
wasn’t aware that both urls would produce an ical, i think that’s just a coincidence, but maybe something we can take advantage of in the future when implementing this feature π
@agelonwl thanks! will look into it. Seems I need to add arguments to the call, and filter based on the category in the argument.
@marcus: I guess this will provide helpful for a lot of users, as the site can actually offer a limited subscription. I don’t have the time nor the resources to tackle this for the coming months. However, I’m willing to look into the filtering, see if there’s a way. Do you have any pointers on using the fact that the category also generates the ical needed?
Followed up in the other thread: click.
Whoa, I got the thing to work! Thanks to the other thread and some trial-and-error on formatting. Funny thing is that this way actually uses the name of the category to generate the category id and filter on this, so this can be used as a general implementation! I added handling for permalinks as well. Here’s the code:
/* Get the category ID */
$uri=$_SERVER['REQUEST_URI'];
$args=explode('/',$uri);
/* handling different permalinks */
if ($args[1]=='index.php') {
$start_index_URI=2;
}else{
$start_index_URI=1;
}
/* retrieve category ID from WP Events Manager DB */
if($args[$start_index_URI]=='events' && $args[$start_index_URI + 1]=='categories') {
$cat_name=$args[$start_index_URI + 2];
$cat_obj=get_term_by('name', $cat_name , 'event-categories');
$cat_id=$cat_obj->term_id;
}
and the loop on (former) line 13:
$EM_Events = EM_Events::get(apply_filters('em_calendar_template_args',array( 'limit'=>get_option('dbem_ical_limit'), 'owner'=>false, 'orderby'=>'event_start_date', 'scope' => get_option('dbem_ical_scope'), 'category'=>$cat_id )) );
So, there’s now three ways to get an export:
1. per event
2. per category: [site]/events/categories/[category name]/events.ics
3. whole calendar: [site]/events/events.ics
Marcus, I guess this is something you can just implement and document? It also works with different permalinks, as stated before.
glad you got it working on your site but to implement this, problem with the above is it probably won’t not work in all cases, e.g. if permalinks are disabled. we’d need to look at $WP_Query and decide that way.
since you can override the ical template I advise you copy that to your theme so you won’t lose changes on updates
Rich
(@rjbwarrenmecom)
I’ve been trying to get this to work but can’t see whereabout in the ical.php file I would need to place this code. Any chance of a pointer?
Thank you in advance,
Richard
probably first snippet at the top of the file, then the second bit on the line he mentioned (you probably replace a line there)