Forums

[resolved] "Junk after document element" in RSS feeds (10 posts)

  1. Slimejam
    Member
    Posted 3 years ago #

    I operate a number of WordPress based sites, and I have just noticed that the RSS feeds for each site fail to validate due to the entire index.php of the root www file being inserted after the XML for the site feeds.

    I am not using any templates, I am running the WordPress loop in my own index.php page for each site.

    I thought it may have been a problem with permalinks, but I tried disabling permalinks on my own site (http://christophermiles.com.au) and the XML is still carrying the invalid HTML code after the document element.

    For an example of the invalid feed, look at the source for http://christophermiles.com.au/feed

    I have seen other posts from people who receive the same XM validation error, but in these cases it seems to be due to javascrip hacks. I can't find evidence of the same on my site. In each case it is the index.php being somehow included in the feed.

    Help or advice would be greatly appreciated.

  2. kmessinger
    Member
    Posted 3 years ago #

    Have you added anything to your index.php file?

  3. Slimejam
    Member
    Posted 3 years ago #

    My index.php at the site root is a page I have created myself, but it runs the WordPress loop within it. I could post the code here if that would be useful.

    Within the WordPress admin interface I have told WordPress to make http://christophermiles.com.au the blog frontpage, but have also told it to recognise http://christophermiles.com.au/blog (where the WordPress files are kept) the directory for the WordPress installed. I have not changed the index.php in the 'blog' directory.

  4. Slimejam
    Member
    Posted 3 years ago #

    So, just to clarify, the 'Wordpress address' (in the admin interface terminology) is http://christophermiles.com.au/blog, and the index.php in this directory is untouched

    The 'Blog address' is http://christophermiles.com.au, and the index.php file here is my own creation, running the WordPress loop.

  5. iridiax
    Member
    Posted 3 years ago #

    The 'Blog address' is http://christophermiles.com.au, and the index.php file here is my own creation, running the WordPress loop.

    This customized index.php sounds like your problem. See:

    http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

  6. Slimejam
    Member
    Posted 3 years ago #

    @iridiax
    Thanks for the link, but as far as I can tell that article doesn't mention anything about feeds. Everything on my site(s) is set up as documented in the article.

    I'm wondering if I should use a conditional tag for is_feed just after the PHP require for wp-blog-header, and use PHP die; if the page is a a feed, so that the rest of the index.php isn't appended to the XML.

  7. Slimejam
    Member
    Posted 3 years ago #

    Yep, that worked.

  8. Slimejam
    Member
    Posted 3 years ago #

    <?php require('./blog/wp-blog-header.php'); ?>
    
    <?php if ( (is_feed() ) ) { die; } /* Hack to stop the rest of the index.php being added to the XML for the site feed */ ?>
  9. kmessinger
    Member
    Posted 3 years ago #

    That worked by the real answer is to leave your index.php alone. If you want to add something put it into header.php.

    You don't have to hack anything to make WP work as it should.

  10. Targenor
    Member
    Posted 3 years ago #

    Whell i belive that kmessinger is wrong, i to have the problem whit junk after element and as you can se, it has nothing to do whit index.php

    <?php
    /**
     * Front to the WordPress application. This file doesn't do anything, but loads
     * wp-blog-header.php which does and tells WordPress to load the theme.
     *
     * @package WordPress
     */
    
    /**
     * Tells WordPress to load the WordPress theme and output it.
     *
     * @var bool
     */
    define('WP_USE_THEMES', true);
    
    /** Loads the WordPress Environment and Template */
    require('../wordpress/wp-blog-header.php');
    ?>

    I haven“t added anything in that file, i did add it in wp-blog-header.php

    It also reacts to posts i have made when i do the rss feed check.
    targenor.se/blogg/?feed=rss2 @ feedvalidator

    Any ideas of what could be wrong?
    sorry if i posted in wrong place

Topic Closed

This topic has been closed to new replies.

About this Topic