SEO Company

Our Blog

Limit the number of sitemap entries – Yoast SEO plugin

website sitemap, yoast, yoast plugin, seo

Limiting the number of sitemap entries can prevent issues associated with sitemaps that have become too large; like the server exceeding set php memory limits whenever compiling large sitemaps.

Before v7.0, Yoast had a feature available which allowed you to limit sitemap entries. Unfortunately this feature has since been removed, since it was not functionality needed for most standard WordPress installations.

However, Yoast has provided the wpseo_sitemap_entries_per_page filter for exceptional use-cases.

</> Code Snippet

Paste the below snippet in your theme’s functions.php.

Warning: as a precautionary measure, always back-up the database and theme files before editing the functions.php file.

OR

If you don’t have access to site files, or you don’t feel comfortable editing these files directly, or you cannot back-up these files before doing so, install and activate Code Snippets and add it as a snippet set to “run everywhere”.

/* Limit the number of site map entries (Yoast SEO plugin) */
function max_entries_per_sitemap() {
return 100;
}add_filter( ‘wpseo_sitemap_entries_per_page’, ‘max_entries_per_sitemap’ );

Adjust the return value (100) to the number of entries you would like to set the limit at.

Contact Us Today

Category

Latest Blog

Contact Us

How Can We Help You?