I'm getting a feed error of 'XML parsing error: :[line number]:0: junk after document element'.

Although such errors often seem to be from unwanted code injections, mine is showing 'Cannot modify header information - headers already sent by'... which I've previously had with unwanted white space.

'Warning: Cannot modify header information - headers already sent by (output started at ...path to... /wp-includes/feed-rss2.php:11) in ...path to custom theme... /feed-rss2.php on line 3<.'

The two files noted in the error, are identical to those in other installs which don't have this error - which seems to trigger at the end of the last-but-one item in the feed.


That depends of what that incomplete path path to... /feed-rss2.php contains. Could be a Plugin, a Theme, a white space in a file, or any syntactic error while modifying or adding something.

It is preferable to omit the PHP closing tag (?>) at the end of the files, in files with pure PHP code, to avoid such probability.

This is a common cause of errors with described error message.

Making a Backup before changes in files is highly recommended to prevent loosing your content.

  • Thanks. Those paths are to wp-includes/feed-rss2.php and a modified variant thereof in the custom theme... which is used with a custom function. All files are identical to those used in another install. – gulliver Sep 2 '16 at 9:35

UPDATE: Seems the code in my functions was the issue - even though it was a direct cut/paste of that working on in another install. Strange.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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