• Resolved AL Guevara

    (@albabes)


    Hello
    I have below code in CS, saved & activated as “Only run on site front-end.” Code is supposed to EXCLUDE a page from Jetpack Sitemap. Its not working.
    https://apschipsealingpaving.com/sitemap.xml

    I already tried the “Only run in administration area” mode also.

    Any clues please?

    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 );
Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter AL Guevara

    (@albabes)

    Plugin Author Shea Bunge

    (@bungeshea)

    I can see that you’ve taken the official snippet from the Jetpack site and are using that. So you’re doing the right thing. The snippet looks like it’s quite poorly written and problematic, however.

    Without setting up a test site for this, I can’t be 100% sure what will fix this problem, but can you try this snippet instead and let me know if it works?

    add_filter( 'jetpack_sitemap_skip_post', function ( $skip, $post ) {
    	if ( 72 === $post->ID ) {
    		return true;
    	}
    	return $skip;
    }, 999, 2 );
    • This reply was modified 7 years, 11 months ago by Shea Bunge.
    Plugin Author Shea Bunge

    (@bungeshea)

    Also, just set this as a global snippet. There’s no reason not to.

    Thread Starter AL Guevara

    (@albabes)

    Thank you Shea.
    Strangely enough after a nite of sleep, the EXCLUDE is working now.
    No more
    https://apschipsealingpaving.com/z-example-html-page/
    and the sitemap.
    https://apschipsealingpaving.com/sitemap.xml

    Must have something to do with the “cacheing?”

    Strange, cause last nite I tried:

    • Private windows.
    • Closing FF/Chrome and re-opening
    • Even Rebooting to boxes
    • To no avail

    Glad its working, but baffled I remain, and I bet/suspect its not CS at all, but the cacheing functions of Jetpack/Sitemap.

    Thanks Shea

    Plugin Author Shea Bunge

    (@bungeshea)

    Yeah, that does make sense. I assume Jetpack only generates the sitemap every so often, rather than on every request. Glad that things are working now, and thank you for testing everything thoroughly last night.

    Thread Starter AL Guevara

    (@albabes)

    global snippet?

    Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    I assume Jetpack only generates the sitemap every so often, rather than on every request.

    Yep, that’s exactly it. The sitemap is cached and only gets regenerated every so often, or when you update a post, or publish something new. That’s most likely why the snippet didn’t seem to work when you first installed it.

    @albabes In the future, if you have questions about Jetpack or a code snippet available in Jetpack, I would recommend posting in the Jetpack support forums for help!

    Thread Starter AL Guevara

    (@albabes)

    Hi Jeremy
    I did post at Jetpack, but because I was using CS to implement the EXCLUDE, I posted here also.

    Can you explain how I do a “global snippet” please?

    Thanks

    • This reply was modified 7 years, 11 months ago by AL Guevara.
    Plugin Author Shea Bunge

    (@bungeshea)

    All I mean by ‘global snippet’ is one where the scope is set to “run snippet everywhere”, rather than “only run in administration area” or “only run on site front-end”.

    Thread Starter AL Guevara

    (@albabes)

    Thank you Shea.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘page exclude function not working’ is closed to new replies.