Support » Plugin: Saeid Simple Text Rotator » Inline script breaks XML Sitemap (2)

  • To follow up on the previous issue reported here. I would like to share a suggestion.

    To recap, I use Yoast SEO. The XML sitemap /page-sitemap.xml has extra jQuery added at the top of the xml file, which breaks the page. Google Search Console reports:
    Unsupported file format – Your Sitemap does not appear to be in a supported format. Please ensure that it meets our Sitemap guidelines and resubmit.
    When I turn off your plugin, the issue is fixed.

    The sitemap xml file looks like this:

    			animation: "spin",
    			separator: "|",
    			speed: 10000
    	<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//"?>
    <urlset xmlns:xsi="" xmlns:image="" xsi:schemaLocation="" xmlns="">

    I have discovered that the shortcode ‘saeidrotate’ is instructed to ‘echo’ an inline js script. This is wrong practice as it breaks the WordPress loops. Instead of using ‘echo’, I recommend returning the script as part of the shortcode function.

    So instead of:
    echo $rotatejquery;
    return $rotatejquery.'<span id="'.$id.'" class="'.$class.'">'.do_shortcode($content).'</span>';

    This has fixed the problem.
    Author, it would be a good idea to implement this in your code if this solution is approved.

  • The topic ‘Inline script breaks XML Sitemap (2)’ is closed to new replies.