• Resolved cjyabraham

    (@cjyabraham)


    Hi,
    How do I exclude all posts from a particular category from my sitemap?

    I’ve tried a few different hooks to achieve this, including the the_seo_framework_sitemap_exclude_term_ids filter, however they haven’t worked.

    Thanks,
    Chris

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • @cjyabraham from robots meta index tab, on general sub-tab you have “Apply noindex to Category archives”
    Steps are: Seo – Robots Meta Index, General, Apply noindex to Cateogry Archive

    Thread Starter cjyabraham

    (@cjyabraham)

    Antonio,
    That doesn’t do what I want to do. I want to omit all posts that belong to a particular category from the sitemap.
    Chris

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi Chris!

    The the_seo_framework_sitemap_exclude_term_ids filter is not used internally–its parent method is a placeholder for when we (or anyone else) wants to display terms in the sitemaps, so they won’t include terms that have noindex set or are excluded via other means.

    Instead, this should do. It allows WP Query to filter posts that are bound to the listed category IDs:

    add_filter( 'the_seo_framework_sitemap_nhpt_query_args', function( $args ) {
    	// Supply an array of category IDs you wish to exclude. How you get them is up to you!
    	$args['category__not_in'] = [ 42, 9001 ];
    
    	return $args;
    } );

    Cheers!

    P.S. Thank you for dropping by and helping out, Antonio ??

    Thread Starter cjyabraham

    (@cjyabraham)

    Thanks Sybre. Here’s my final commit.

    Plugin Author Sybre Waaijer

    (@cybr)

    I didn’t know about the cat argument ?? Looks good to me!

    Have a nice day! ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Exclude category from sitemap?’ is closed to new replies.