Broken Feeds – CiviCRM and WordPress

If you are using the CiviCRM system along with WordPress you will most likely be getting some errors when trying to utilize the event feeds (rss & ical). The error message “Entity ‘raquo’ not defined” comes from WordPress inserting html in the pages that CiviCRM is trying to generate. This is actually a great thing for some of the pages but wreaks havoc on the feeds.

The other issue (once we get past that first one) is an encoding error that is happening somewhere in CiviCRM that causes an XML error on the link url. It happens because it builds the url using an ampersand (&) in one spot and that throws the encoding error. I didn’t quite figure out where that is generated from as I didn’t have time to go through all of the files but I do have a work around to keep the rss feed from throwing the error.

I might point out that I started down this road in an effort to put the CiviCRM events in a WordPress widget, something that should be pretty simple and valuable right? Well, follow along and you’ll see how I managed to get it working. Caveat, these instructions involve making changes to core CiviCRM files and will be overwritten when updated. Hopefully fixes make it into the code before then 🙂

The first file we need to edit is wp-content/plugins/civicrm/civicrm.php. This is where we will tell CiviCRM to strip the html WordPress wants to put in. Insert the code in red below at line 374:

add_filter('init', 'civicrm_wp_invoke');
// strip rss html added by gs
if (civicrm_wp_in_civicrm() &&
$_GET['q'] === 'civicrm/event/ical' && $_GET['html'] != '1') {
CRM_Utils_System::civiExit( );

This is what you should end up with:

CiviCRM WordPress Fix
To get rid of the XML error we need to edit:


I’ve highlighted all the changes I made to mine in red though you only need to add the CDATA section to have the XML parser skip that part that is encoded wrong. Since I was in here, I changed the title for mine and commented out the Harvard link.

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<title>{ts}Leadership Napa Valley Public Calendar{/ts}</title>
<description>{ts}Listing of current and upcoming public events.{/ts}</description>
{foreach from=$events key=uid item=event}
<link><![CDATA[{crmURL p='civicrm/event/info' q="reset=1&amp;id=`$event.event_id`" fe=1 a=1}]]></link>

Now if you’re like me, you’re doing all of this to get an upcoming event widget in your sidebar so here’s how I did mine.

CiviCRM Event Link WordPress

Add link to event widget

  1. Install and activate amr ical events list from the WordPress plugin directory.
  2. Grab your feed url by going into your events dashboard in CiviCRM, right clicking on the calendar icon and copying the link address.
  3. Drag the new upcoming event widget into the appropriate sidebar and paste your link into the external ics url box at the bottom and save.

That’s it, now you should have a CiviCRM | WordPress event widget like so:

CiviCRM WordPress Event Widget

Hope this helps someone out there and keep on WordPressing!!

  1. David Esrati September 2, 2013 at 4:59 pm #

    Thanks for this tip- but, why does this have to be so complicated? Both the Drupal and Joomla versions of CiviCRM make this a piece of cake.

    • gsibert September 18, 2013 at 4:07 pm #

      Actually you shouldn’t need to go through all of this now as the core files have been updated. And I would just say the the WordPress version of this was the last to the party so the code isn’t developed quite as much as the Drupal & Joomla versions.

Leave a Reply