I'm trying to create a custom RSS feed template for a site my company manages, and I've encountered a very confusing bug I'd like some input on.
First off, as background context, after a lot of Googling, this is the method I've chosen to create the RSS template. (If there's a better approach, I'm all ears):
- Copy /wp-includes/feed-rss2.php into my theme folder
- Specify that file as a page template, and modify as desired
- From the Wordpress backend, create a new page that uses the above template
From there, you get an XML feed that's formatted for RSS. That process seems to work fine, even if it's a bit kludgy.
Now, here's the issue I'm having. The XML outputted looks something like this:
<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" > <channel> <title>New Grocery Coupons & Online Coupons Added Daily</title> <atom:link href="http://couponkim.dev/weekly-deals-rss/" rel="self" type="application/rss+xml" /> <link>http://couponkim.dev</link> <description>Coupon Kim has online coupons, printable coupons, and coupon code section for Moms like me trying to save money!</description> <lastBuildDate>Mon, 18 Apr 2011 14:51:44 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1</generator> <item> <title>coupon-code</title> <link>http://couponkim.dev/soap-com-coupons/coupon-code-159/</link> <comments>http://couponkim.dev/soap-com-coupons/coupon-code-159/#comments</comments> <pubDate>Mon, 18 Apr 2011 13:46:18 +0000</pubDate> ...
(I've truncated the output for the sake of relevancy.)
When I try to view the above in a Google Chrome, I get the following error message:
error on line 12 at column 30: xmlParseEntityRef: no name
My assumption here is that the ampersand is causing problems, though honestly, that's still a guess at this point.
OK. So this is where it starts to get weird. I went into the PHP template, and embeded that title inside of a CDATA tag. Strangely, I didn't see that change reflected in the output when I refreshed the page.
Trying something simpler, I just killed all of the PHP in the template inside of the title tags, and replaced it with static text like "This is a Test." When I refreshed the page, I still didn't see any change in the output.
At that point, I suspected that some cache somewhere must be working against me. I disabled the W3 Total Cache plugin, cleared my browser's cache (I'm using Chrome), and restarted Apache for the hell of it. I reloaded the page again, but saw no change.
Now, as an experiment, I changed the
<title></title> tags to read
<test></test> and reloaded. This time, I did see the change.
So at this point, I thought, OK, cool, I'm finally breaking through the cache. I changed the line back to:
<title>This is a Test</title>, but saw outputted
<title>New Grocery Coupons & Online Coupons Added Daily</title>.
So that's where I am. I've got literally no clue what the problem could be at this point.
Here's one more weird thing to know, though. When I changed the
<title> tags to
<test>, and did see the change made on line 12, the next title tags (at channel->item->title at line 22) changed to read
<title>New Grocery Coupons & Online Coupons Added Daily</title> - ie, the troublesome output from line 12!
My best guess is that there is some Wordpress filter that I don't know about that's operating on this output, but I'm really stumped at this point. Any light you guys could shed on this problem would be very much appreciated!
Thanks in advance.