Editing wp-sitemap.xml
-
Hi,
I’m trying to follow:
specifically the excluding a single post from the sitemap part. This was the code that was suggested:
add_filter( 'wp_sitemaps_posts_query_args', function( $args, $post_type ) { if ( 'post' !== $post_type ) { return $args; } $args['post__not_in'] = isset( $args['post__not_in'] ) ? $args['post__not_in'] : array(); $args['post__not_in'][] = 123; // 123 is the ID of the post to exclude. return $args; }, 10, 2 );I replaced 123 with the correct post ID but it’s still displaying the page on the sitemap. Do I need to add anything if it’s for a page since this instruction is for a post.
Please help. Thanks
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Editing wp-sitemap.xml’ is closed to new replies.