How To Fix RSS Feed Validation Error for WordPress Site Name with Trademark

How to Fix RSS Feed Validation Issues
How to fix RSS Feed validation errors when your WordPress site name has a special symbol like a trademark as part of the name.

A while ago, I decided I wanted to add the trademark symbol (™) to my WordPress site name – HighTechDad – so that all pages and articles would have “HighTechDad™” tagged on to the end of each page title. This process was easy enough to do, but little did I know that by doing it, it would actually break my RSS feed’s validity. While not many people use RSS directly anymore, there are content aggregation sites (like Feedly) that pull in RSS feeds in order to display the content. I’m not a web developer so the fix was not something immediately apparent to me. And I did a bunch of investigation to try to first understand the issue, and then to fix it. Alas, I failed. But I was saved by the coding expertise of Shane Bishop, the brains behind the incredible plugin, EWWW Image Optimizer which can compress the images on your WordPress blog in order to make it serve content faster. (By the way, I highly recommend his plugin!) So, I can’t take ANY credit for the fix that follows! (Just the documentation of it.)

Here’s what the issue was. Since an RSS feed is essentially an XML document, this XML document needs to adhere to some very strict standards in order for it to be valid. But first, a little background. I have my feed “hosted” with Google’s Feedburner service (an RSS service which lets you not only host a feed, but also “clean it up” and add other options to it). While Google hasn’t killed the service, it really has discontinued any development on it. But it still works. Recently, I was adding my site to an Influencer service, and part of the process was to add in my site’s RSS feed. When I did that, the service couldn’t pull my feed. It was broken.

So, I went over to the “Troubleshootize” tab on Feedburner and decided to check the “Original Feed Validity” (which uses FeedValidator.org to do so). The result I got was interesting.

RSS Feed Validation Error

On line 3, there was an interesting error: “XML parsing error: <unkown>:3:18: undefined entity“. Directly below that was my site’s title which showed “HighTechDad&trade;” with a little red arrow pointing at the “&” (ampersand). After a bit of research (first starting on this page from the “help” link), I learned that in XML, you are forbidden from using an “&” (ampersand) symbol. Update: actually, Shane corrected me in this statement. It’s not that the ampersand is forbidden in XML, it’s just that XML only supports a few types of XML (as outlined here). The HTML symbol for trademark is one of those not supported.

Once I understood that fact, I started digging into how I could change the &trade; into the actual symbol “™” but that proved to be pretty complicated as WordPress really likes converting symbols into HTML character and was automatically converting from the symbol to the “&trade;” code. Grrr.

There were solution references to wrapping the text within CDATA declarations (there are items in the feed that have that like with Categories), but I realized I didn’t have a clue on how to do it. I knew the concept, but not the implementation. Essentially, I wanted to add a function to my WordPress “functions.php” file within my theme folder to do this parsing. But, I’m not a coder, I only know how to copy and hack things together.

After reading lots of related issues and ways to fix, as well as diving into the WordPress feed code and understanding that I needed to focus on the “bloginfo” element, I figured I needed some help. Since I had worked with Shane (of EWWW Image Optimizer) on troubleshooting an issue I was encountering on my site with his plug-in, and after looking at his hundreds of lines of code, I reached out for help (note: he doesn’t do support work like this that is NOT related to his plugin!).

I explained the situation and my thoughts and he came back with not only a tutorial on how to fix my particular issue, but also the fix itself which I will detail below.

How to Fix RSS Feed Validation Error when Site Name has a Special Symbol

So, the fix that Shane provided should work for other special symbols or characters if they are part of your site’s name within WordPress. The fix below is specific to the trademark symbol but you could probably just as easily do it with “®” or others.

Here’s what Shane explained (so you can get a quick WordPress coding lesson here):

You would want to use the bloginfo filter.

Hook onto it like this:

add_filter( 'bloginfo', 'my_bloginfo_filter_function', 10, 2 );

That tells WP to send the particular piece of blog information along with the type of the information to the function ‘my_bloginfo_filter_function‘. Which could look something like this:

function my_bloginfo_filter_function( $output, $show ) {
if ( strpos( $_SERVER['REQUEST_URI'], 'feed' ) !== false && ( empty( $show ) || $show == 'name' ) ) {
return str_replace( '&trade;', '™', $output );
}
return $output;
}

That looks to see if the current ‘page’ or request URI contains the word ‘feed’, and $show is either empty, which means the get_bloginfo() function returns the blog name by default, or $show is ‘name’, which of course does the same. Then it replaces the html entity with the actual trademark symbol, but you could also replace it with nothing, and empty string like ” (two single quotes) if the parser doesn’t like the trademark symbol either. From what I read though, xml defaults to utf8, so it should be ok.

Then, of course with any filter, you need to return the unaltered value if your condition doesn’t match, so that’s what the last line of the function does. Assuming I have no syntax errors, that should do the trick. If it breaks your blog, just remove the stuff you added, and it should go back to normal.

So then it was up to me to apply this fix. Here’s how I did it:

  1. Open your functions.php file – I would highly recommend NOT using the WordPress file editor and doing it directly on the file via FTP/SFTP. I found that sometimes the HTML symbol code was actually replaced by WordPress mysteriously. The functions.php file is usually found in your active theme’s directly (or in my case, a child theme directory).
  2. Identify the section to place the code – Hopefully, the theme developer has carefully documented where custom functions should go. By using the theme’s custom functions, you don’t have to edit any core WordPress files (which may be updated and have your fixed overwritten).
  3. Place the code – It’s important to note that you need to put in both parts of the code listed above. I actually put the add_filter line in after the function declaration itself. (See the image below for what it looks like in my functions.php file.
  4. Save your changes – Upload the functions.php file back to your server.
  5. Flush caches – If you have any caching plugins or services, be sure to flush the cache.
  6. Go re-validate your original RSS feed – Validate your work!

That’s it! Here’s what the code looks like in my functions.php file within my child theme directory.

RSS Fix In Functions.php for Trademark

And, once I went to re-validate my original feed on FeedValidator.org, I was met with positive results. Oh, one more thing I should note. I was using a Feedburner redirection plugin to redirect my blog’s original feed to Feedburner. You should DISABLE plugins that do this, otherwise, when FeedValidator grabs your feed, it will not be getting your original site RSS feed.

Here’s what my fixed RSS feed validation now looked like after applying the fix.

RSS Feed Valid

And, if you look in between the title tags, you will see the trademark symbol and NOT the “&trade;” text.

Then, just be sure you re-activate your Feedburner redirection plugin (if you are using one). I then took a look at my RSS feed which redirected automatically to my Feedburner version of my feed and it all looked great!

Feedburner RSS Feed Working

So again, I cannot take ANY credit for this fix. This was all Shane’s brainpower! If this fix worked for you, be sure to send him a thank you on his Twitter or Facebook account. (And try out his plug-in if you need images optimized on WordPress!)

How to Fix RSS Feed Validation Issues

I do hope that you found this solution helpful. Just remember, if you add the code and it breaks your site, it is easy enough to just remove it. Sometimes characters within the code can be hard to decipher (like ” vs ” – the first one is a double quote and the second is two single quotes). Feel free to leave a comment about this if the fix did (or did not work) for you. I’m not a coder, but others who are reading this article might be able to help.

HTD says: I’m always amazed at how something done very innocently (like adding a symbol to the name of your WordPress site) can have downstream implications you don’t immediately think about. Luckily, there is always a fix!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Other articles of interest

Global Product Review Disclosure

Disclosure: This is a global disclosure for product review articles on HighTechDad. It does not apply to Automobile reviews and there are other exceptions. Therefore, it may or may not be applicable to this particular article. I may have a material connection because I may have received a sample of a product for consideration in preparing to review the product and write this or other content. I was/am not expected to return the item after my review period. All opinions within this and other articles are my own and are typically not subject to the editorial review from any 3rd party. Also, some of the links in the post above may be “affiliate” or “advertising” links. These may be automatically created or placed by me manually. This means if you click on the link and purchase the item (sometimes but not necessarily the product or service being reviewed), I will receive a small affiliate or advertising commission. More information can be found on my About page.

About HighTechDad

Michael Sheehan (“HighTechDad”) is an avid technologist, writer, journalist, content marketer, blogger, tech influencer, social media pundit, loving husband and father of 3 beautiful girls living in the San Francisco Bay Area. This site covers technology, consumer electronics, Parent Tech, SmartHomes, cloud computing, gadgets, software, hardware, parenting “hacks,” and other tips & tricks.

Recent Articles

Explore Categories