@hankris This error is typically caused by that the resources required to generate the sitemap are not available or the request is timing out due to the resource restrictions of the server environment.
To resolve this, we would first recommend ensuring that the PHP settings for both max_execution_time and memory_limit are set to a high enough value in the PHP environment. This setting is typically controlled by editing the values in a php.ini file such as in the following example:
max_execution_time = 300
memory_limit = 256M
If you aren’t sure how to change these settings in php.ini, we would recommend contacting your hosting provider for additional assistance.
If you are still receiving the critical error on the sitemaps after increasing both values for the PHP max_execution_time and memory_limit, the issue may be caused by that the PHP script run time restriction on the server is being reached.
In order to reduce the amount of time necessary for the script to generate the sitemap, you can reduce the number of entries in the sitemap.
By default, the number of entries in the sitemap is set to 1000 but by decreasing this value it will decrease the amount of resources required to generate the sitemap. To decrease the number of sitemap entries you can use the filter wpseo_sitemap_entries_per_page.
For example, here is example code to limit the number of sitemap entries to 100:
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Limit the number of sitemap entries for Yoast SEO
* Yoast SEO defaults to 1000
*/
function max_entries_per_sitemap() {
return 100;
}
add_filter( 'wpseo_sitemap_entries_per_page', 'max_entries_per_sitemap' );
We also have more information on using this developer filter at the following link: Limit the number of sitemap entries entries.
increasing the max_execution_time did not change the behavior … where do I enter the php code for wpseo_sitemap_entries_per_page ?
function max_entries_per_sitemap() { return 100; } add_filter( ‘wpseo_sitemap_entries_per_page’, ‘max_entries_per_sitemap’ )
Typically code snippets are added to your theme’s functions.php file. If you’re unfamiliar with using code snippets, we’d like to refer you to the WordPress documentation on how to use a filter.
Thank you very much! That worked!