Closed abderrahmaneizri closed 1 year ago
Hi, you could use a filter to disable the sitemap index at runtime:
add_filter( 'option_xmlsf_sitemaps', function( $sitemaps ) { $sitemaps['sitemap'] = false; return $sitemaps; } );
The filter should be added before init (or, if at init, before position 9)...
Hi, you could use a filter to disable the sitemap index at runtime:
add_filter( 'option_xmlsf_sitemaps', function( $sitemaps ) { $sitemaps['sitemap'] = false; return $sitemaps; } );
The filter should be added before init (or, if at init, before position 9)...
Thanks for the quick reply.
Could you please clarify where exactly this filter should be added? Which php file exactly?
Sorry for my ignorance.
Thanks!
EDIT:
We've added the filter to our theme's functions.php file and it worked. Thanks! Here's an example of how to enable it using that filter:
add_filter( 'option_xmlsf_sitemaps', 'customize_xml_sitemap_index' );
function customize_xml_sitemap_index() {
$sitemaps['sitemap'] = true;
return $sitemaps;
}
Hi @abderrahmaneizri sorry I missed your follow-up question. Good to hear you got it working!
Please note: your modification will be lost if you get a theme update (if you are not using a custom theme) or if you switch to another theme. In that case, you could consider adding the PHP snippet via a plugin like "WPCode" or "Code Snippets" for example. They can be found via Plugins > Add new.
Hi,
This is more of a question rather than an issue, depending on how you view it.
I am currently working on a WordPress website that's using this plugin, and I'd like to know if it's at all possible to enable/disable the XML Sitemap Index via PHP hooks or by updating some options or fields in the WordPress database. Or is it only possible to do that through the admin dashboard as described in the FAQ on the plugin's main page (Settings > Reading)?
Thanks