Skip to content

disable Jetpack’s image/video/…sitemap while keeping the normal (post/page/link) sitemap active

Here’s the cleanest, most reliable way to disable Jetpack’s image sitemap while keeping the normal (post/page/link) sitemap active, based on the filters documented in community discussions and Jetpack’s own developer resources.


✅ How to Disable Jetpack’s Image Sitemap (but keep the main sitemap)

Jetpack provides a filter that allows you to skip all images from being added to the image sitemap:

add_filter( 'jetpack_sitemap_image_skip_post', '__return_true' );

This filter tells Jetpack to exclude every image entry, effectively disabling the image sitemap while leaving the post/page/link sitemap untouched.

Why this works

  • Jetpack generates separate sitemaps for posts, images, and videos.
  • The filter jetpack_sitemap_image_skip_post is specifically designed to skip image entries.
  • Jetpack regenerates sitemaps every ~12 hours, so changes may not appear immediately.

📌 Steps to Apply

  1. Go to Appearance → Theme File Editor or use a custom plugin / Code Snippets plugin.
  2. Add this line to functions.php or a custom functionality plugin:
add_filter( 'jetpack_sitemap_image_skip_post', '__return_true' );
  1. Wait for Jetpack’s next sitemap regeneration (up to 12 hours), or manually trigger WP‑Cron if needed.

🧪 Confirming It Worked

After regeneration:

  • sitemap.xml → still works
  • post-sitemap.xml → still works
  • page-sitemap.xml → still works
  • image-sitemap.xml → now empty or removed

Users have confirmed that the filter works after the next cron-based rebuild.



Remove Jetpack Video Sitemaps

You’ve already cleaned up image sitemaps and attachment pages — removing Jetpack’s video sitemap fits neatly into the same pattern. Jetpack exposes a filter that controls whether the video sitemap is generated at all.

See also  How to disable "XML-RPC" - a popular backdoor that hackers often use to bypass login pages?

Add this filter to your functions.php or Code Snippets plugin:

add_filter( 'jetpack_sitemap_generate_video_sitemap', '__return_false' );

This completely disables Jetpack’s video-sitemap.xml while keeping all other sitemap types intact.


✅ Remove WordPress Attachment Pages (Disable + Redirect)

If your goal is to remove WordPress attachment pages (so they don’t appear in search results or Jetpack sitemaps), the cleanest solution is to disable attachment pages entirely and redirect them back to their parent post (or to the homepage if no parent exists). This is a standard SEO‑friendly approach and works perfectly alongside Jetpack’s sitemap system.

Add this to your theme’s functions.php or a Code Snippets plugin:

// Disable attachment pages and redirect them
function disable_attachment_pages() {
    if ( is_attachment() ) {
        global $post;

        // If the attachment has a parent post, redirect there
        if ( ! empty( $post->post_parent ) ) {
            wp_redirect( get_permalink( $post->post_parent ), 301 );
            exit;
        }

        // Otherwise redirect to homepage
        wp_redirect( home_url(), 301 );
        exit;
    }
}
add_action( 'template_redirect', 'disable_attachment_pages' );

📌 What this accomplishes

  • Attachment pages no longer load
  • They won’t appear in Jetpack sitemaps
  • They won’t appear in Google search results
  • Users are redirected to the relevant post instead of a thin, low‑value page

This is the same behavior Yoast SEO uses when you enable “Redirect attachment URLs”.


🧹 Optional: Also remove attachments from Jetpack sitemap explicitly

If you want to be extra strict:

add_filter( 'jetpack_sitemap_include_post_type', function( $include, $post_type ) {
    if ( 'attachment' === $post_type ) {
        return false;
    }
    return $include;
}, 10, 2 );

This ensures Jetpack never includes attachments in any sitemap.


✅ Remove Specific Custom Post Types From Jetpack Sitemaps

Replace your_cpt_slug with the slug of the custom post type you want to exclude:

add_filter( 'jetpack_sitemap_include_post_type', function( $include, $post_type ) {
    $blocked = array(
        'your_cpt_slug',   // add your CPTs here
        'another_cpt_slug'
    );

    if ( in_array( $post_type, $blocked, true ) ) {
        return false;
    }

    return $include;
}, 10, 2 );

This removes the CPT from:

  • post sitemap
  • page sitemap
  • custom post type sitemap
  • image/video sitemaps (if they were enabled)
See also  Adding subtitles in multiple languages to videos on a WordPress website

Jetpack simply stops indexing that post type entirely.


Leave a Reply

error: Content is protected !!