Support » Plugin: Jetpack - WP Security, Backup, Speed, & Growth » exclude page/post > Jetack sitemap, which function is correct?

  • Resolved AL Guevara

    (@albabes)


    Exmple 1

    function jeherve_exclude_post_sitemap( $skip, $post ) {
            if ( '72' ==  $post->ID ) {
                    $skip = true;
            } else {
                    $skip = false;
            }
            return $skip;
    }
    add_filter( 'jetpack_sitemap_skip_post', 'jeherve_exclude_post_sitemap', 10, 2 );

    Shea Bunge (@bungeshea) says:

    add_filter( 'jetpack_sitemap_skip_post', function ( $skip, $post ) {
    	if ( 72 === $post->ID ) {
    		return true;
    	}
    	return $skip;
    }, 999, 2 );
Viewing 2 replies - 1 through 2 (of 2 total)
  • They will both work, most of the time. Personally, I would use the second one, as the first one has a bit of a problem with it. If this is the only time you are using that filter in a snippet or plugin or theme, etc, then it will work fine. If you are using it multiple times, then it will cause problems.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    Both will indeed work, but the latter is best, as long as your server’s PHP version is higher than PHP 5.3.

    I’ve updated the filter’s documentation accordingly.

    @bungeshea Thanks for the feedback!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘exclude page/post > Jetack sitemap, which function is correct?’ is closed to new replies.