Hi there,
I am trying to export my feed as an ical and am having two problems:
- Long descriptions get truncated
- HTML links present in the original description get stripped
I am importing into a 3rd party html5 app creator site, but have had no issues importing rich text ical feeds before.
Any help with these two issues much appreciated.
Thanks!
Shimrit Elisar
Hi Shimrit,
By default the excerpt is used for the event content in the iCal feed. You can change this in one of two ways.
-
Copy the ical.php
template into your theme and edit (see this line – you can replace get_the_excerpt()
with get_the_content()
.
-
Or you can use the filter eventorganiser_ical_description
.
e.g.
add_filter( 'eventorganiser_ical_description', 'my_set_ical_event_description' );
function my_set_ical_event_description(){
$description = wp_strip_all_tags( html_entity_decode( get_the_content(), ENT_COMPAT, 'UTF-8' ) );
$description = ent2ncr( convert_chars( $description ) );
return $description;
}
You’ll notice that I’ve stripped HTML tags in the above. This brings me to your second point. The iCal specification doesn’t mention HTML anywhere, so some calendar clients, when they receive HTML in event content simply treat it as text. For this reason, the HTML is stripped out.
For calendar clients that support it there is a X-ALT-DESC;FMTTYPE=text/html
tag which contains the full event content in HTML.
If your calendar client does not, then you can use the above filter (or edit the template) to ensure that the HTML is not stripped out, but just keep in mind that some calendar clients will display the HTML tags rather than render them.
Stephen Harris
Hey,
Thank you very much for the detailed reply! Could you please let me know exactly how the edited template above should look if I remove the HTML stripping? I don’t know php so when I tried to remove bits, it broke the feed 🙂
Thanks again,
S
Shimrit Elisar
Something like:
add_filter( 'eventorganiser_ical_description', 'my_set_ical_event_description' );
function my_set_ical_event_description(){
$description = get_the_content();
$description = ent2ncr( convert_chars( $description ) );
return $description;
}
should work, but it would depend on what your calendar is expecting.
Stephen Harris