Quantcast
Channel: Active questions tagged yoast - Stack Overflow
Viewing all articles
Browse latest Browse all 97

Wordpress Yoast exclude posts from XML sitemap

$
0
0

I’m using Yoast SEO plugin and I'm trying to exclude posts manually from posts XML sitemap using 'wpseo_sitemap_entry' filter but so far have no luck.

This is my current code:

function sitemap_exclude_post( $url, $type, $post) {    if($post->ID == 6298 ) {        return false;    } return $url;}add_filter( 'wpseo_sitemap_entry', 'sitemap_exclude_post', 1, 3 );

Any suggestions will be much appreciated?

Note: I know it can be done via Yoast plugin's backend by manually entering post IDs but I need to do it via filters. The above code is going to be further changed later to automatically obtain Post IDs of posts(single.php) from a category in wordpress.


Viewing all articles
Browse latest Browse all 97

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>