Quantcast
Channel: Topic Tag: xml | WordPress.org
Viewing all articles
Browse latest Browse all 3201

Inline script breaks XML Sitemap (2)

$
0
0

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:

	<script>
	jQuery(document).ready(function(){
		jQuery("#mwtxmtlv.rotate-text").textrotator({
			animation: "spin",
			separator: "|",
			speed: 10000
		});
	});
	</script>
	<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//www.ergo3.co.uk/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

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;
use
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.


Viewing all articles
Browse latest Browse all 3201

Trending Articles