Monday, July 13, 2020
HighTechDad.com Articles Fix It How To Fix RSS Feed Validation Error for WordPress Site Name with...

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

Must Read

This Device Should Be Font & Center in Every Smart Home – Nest Hub Max Review

Review of the Nest Hub Max - a 10" smart home hub for the Google Home ecosystem with glorious sound, steller HD video, and vast tech integrations.

HighTechDad’s Father’s Day 2020 Gift Guide

This is HighTechDad's 2020 Father's Day Gift Guide of family tech and smart home products that have been reviewed on HighTechDad.com. Happy Father's Day!

Can’t Find TP? Use a Smart Bidet & Wash Your Butt Instead! – Stay At Home Tech Tip Video

Avoid having to hoard toilet paper by installing a smart bidet in your home. This DIY project is easy & you save the environment by conserving toilet paper.

4 Ways to Make a “Distanced” Mother’s Day Better with a Nixplay Digital Frame

Social Distancing may make Mother's Day a bit more difficult. With a Nixplay digital frame you can share memories remotely!

Video Conferencing? Check Broadband Upload Speed – Stay at Home Tech Tip

Having a fast broadband connection at home is critical during the Shelter at Home due to COVID19/coronavirus. Learn what is important now!
- Advertisement -

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

- Advertisement -

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

- Advertisement -

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!

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.

Leave a Reply

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

- Advertisement -
- Advertisement -

Hot Articles

Instagram Users – How to Clear the Instagram Cache & Save Space on your Smartphone

If you are a heavy Instagram user, you might not know this but the more you use Instagram, the...

Instagram Users – How to Clear the Instagram Cache & Save Space on your Smartphone

If you are a heavy Instagram user, you might not know this but the more you use Instagram, the photo-sharing service and mobile application,...

How To Hook Up a DISH Wireless Joey & Extend Your Viewing Without Wires

Setting up a DISH Wireless Joey is extremely easy and takes less than an hour. Here are the steps and what to expect in the setup process.

How to Remove Little Black Square Paragraph Formatting & Page Break in Microsoft Word

Recently, I received a panicked email from my step-mom wondering why a page break could not be removed from Microsoft Word. Normally, if you...

How To Restore a Previous Version of an iOS App

Steps on how to restore a previous version of an iOS app in case you want to roll-back or revert to the previous version.
- Advertisement -

More Articles Like This