WordPress Themes – Watch Those Spaces!

As I mentioned previously, I've been learning WordPress stuff over the last few weeks for a client.  Recently we discovered her RSS feed wasn't working in some checkers, so I checked it and found that the resulting XML had indention before the first few lines.  Now, personally I think its stupid that any reader can't handle that, but well, it is what it is.

But why would something as mature as WordPress have such an elementary issue?  Did some hunting around and found it wasn't an issue with WordPress itself, but that it could be an issue introduced by the theme you choose to use.  See if you have any spaces at the end of the function.php file within your theme, it can cause that indenting of the first line of the XML. 

Now, I have absolutely no idea how the heck a single space results in a two-tab sized indent, but I do know that once I removed the trailing spaces from the function.php file, it fixed the issue – with a catch. See her theme is a child theme of one of the standard themes of the site, made to allow more flexibility in changing the theme without updating the original theme (per best practices from WordPress).  

So fixing the trailing space in her theme's function.php wasn't enough to fix it alone…thay's right, the theme itself had said trailing space.  Now, I think that's particularly asinine since that theme was one distributed by WordPress itself as the .com version of one available in the .org's theme directory.  It's also a good reminder that while theme developers may make some pretty awesome themes, they may not always think about that trailing space or think to check and make sure their theme wasn't messing up the RSS feed.