Yoast sitemap error
This page contains the following errors:
error on line 5 at column 6: XML declaration allowed only at the start of the document Below is a rendering of the page up to the first error.
The page I need help with: https://cheapwebhostpro.com/blog/sitemap_index.xml
SamA74
2
There are 4 blank lines of whitespace beginning the document.
These need to be removed, with the declaration on the first line.
in which file please specify
The error usually happens due to extra spaces before <?xml
. Try:
- Removing any extra spaces in
functions.php
or plugins.
- Disable and re-enable Yoast to regenerate the sitemap.
- Clear your cache and test again.
Tnx but didnt work
below is my functions.php
<?php
function cream_magazine_child_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); // Enqueue parent styles
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style'), '1.0' ); // Enqueue child styles
}
add_action( 'wp_enqueue_scripts', 'cream_magazine_child_enqueue_styles' );
function add_clarity_script() {
?>
<?php
}
add_action( 'wp_head', 'add_clarity_script' );
// Completely disable the Heartbeat API (Use with caution) but SPEEDUP SITE
add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
wp_deregister_script('heartbeat');
}
?>