WordPress filter hook

wpseo_exclude_from_sitemap_by_post_ids

Fired by 4 WordPress plugins, running on 10M+ sites between them.

“Filter: 'wpseo_exclude_from_sitemap_by_post_ids' - Allow extending and modifying the posts to exclude.”

How to use wpseo_exclude_from_sitemap_by_post_ids

It's a filter: your callback receives the value, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', function( $excluded_posts_ids ) {
	// Change $excluded_posts_ids here.
	return $excluded_posts_ids;
}, 10, 1 );

Argument names come from Yoast SEO's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

4 plugins that fire wpseo_exclude_from_sitemap_by_post_ids

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. Yoast SEO icon Yoast SEO10+ million installs apply_filters( 'wpseo_exclude_from_sitemap_by_post_ids', $excluded_posts_ids ) inc/sitemaps/class-post-type-sitemap-provider.php:296
  2. TranslateRocket icon TranslateRocket200+ installs apply_filters( 'wpseo_exclude_from_sitemap_by_post_ids', array() ) src/Frontend/Sitemap.php:298
  3. Rank Authority icon Rank Authority60+ installs apply_filters( 'wpseo_exclude_from_sitemap_by_post_ids', [] ) includes/class-ra-sitemap-manager.php:2508
  4. Langferry icon LangferryFewer than 10 installs apply_filters( 'wpseo_exclude_from_sitemap_by_post_ids', array() ) includes/class-seo-plugins.php:96

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.