Hi … apparently I have found some function on my function.php file was the culprit of this behaviour.
I would like to know what is wrong with it. It is some code to generate a sitemap.
here it is:
/* sitemap */
add_action( "save_post", "sitemap" );
function sitemap() {
$posts = get_posts( array(
'numberposts' => -1,
'orderby' => 'modified',
'post_type' => array( 'post', 'page' ),
'order' => 'DESC'
));
header('Content-Type: text/xml; charset=' . get_bloginfo('charset'), true);
header('X-Robots-Tag: noindex, follow', true);
$sitemap .= '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?> <?xml-stylesheet type="text/xsl" href="' . get_stylesheet_directory_uri() . '/sitemap.xsl' . '"?> <!-- generated-on="' . date('Y-m-d\TH:i:s+00:00') . '" --> <!-- generator-version="1.0" --> <urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> ';
$sitemap .= '<url> <loc>' . esc_url( home_url( "/" ) ) . '</loc> <changefreq>Daily</changefreq> <priority>1.0</priority> </url>'; foreach( $posts as $post ) { setup_postdata( $post); $postdate = explode( " ", $post->post_modified );
$sitemap .= '<url> <loc>' . get_permalink( $post->ID ) . '</loc> <lastmod>' . $postdate[0] . 'T' . $postdate[1] . '+00:00' . '</lastmod> <changefreq>Weekly</changefreq> <priority>0.5</priority> </url>'; } $sitemap .= '</urlset>'; $fop = fopen( ABSPATH . "sitemap.xml", 'w' );
fwrite( $fop, $sitemap ); fclose( $fop ); }
/*end of sitemap */