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):

  1. Copy /wp-includes/feed-rss2.php into my theme folder
  2. Specify that file as a page template, and modify as desired
  3. 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"

    <title>New Grocery Coupons & Online Coupons Added Daily</title> 
    <atom:link href="http://couponkim.dev/weekly-deals-rss/" rel="self" type="application/rss+xml" /> 
    <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> 
        <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.

1 Answer 1


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):

Second time this comes up today. :) You should use add_feed() ( source ) rather emulate this stuff with page.

As for issue you describe I am not sure. If caching is involved I'd try to test stuff on separate local test installation.

  • Thanks for the response, Rarst. I'll just give this another go the right way using add_feed(). Hopefully the bug will disappear as magically as it appeared if I stop relying on kludges. Commented Apr 19, 2011 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.