• Resolved Martin Blumenfeld

    (@monkeypress)


    How would I go about excluding a particular post type from the sitemap and also from being indexed by Google? I also want to exclude the SEO box. These are custom post types defined by a plugin so I can’t edit them.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi @monkeypress,

    In the past two years TSF moved to supporting as much as possible automatically ??

    Now, to revert that process, I believe these filters should do the trick (untested!):

    //* This removes SEO metabox, SEO Bar and sitemap support.
    add_filter( 'the_seo_framework_supported_post_type', function( $post_type, $evaluated_post_type = '' ) {
    	
    	if ( 'my_post_type' === $evaluated_post_type ) {
    		return false;
    	}
    
    	return $post_type;
    }, 10, 2 );
    //* This adds noindex on the post type pages
    add_filter( 'the_seo_framework_robots_meta_array', function( $meta = array() ) {
    
    	if ( 'my_post_type' === get_post_type() ) {
    		$meta['noindex'] = 'noindex';
    	}
    
    	return $meta;
    }, 10, 1 );
    

    You can add that to your theme’s functions.php file or a custom plugin. Do not forget to change “my_post_type” to your post type name ??

    • This reply was modified 7 years, 7 months ago by Sybre Waaijer. Reason: Fixed code, had a fatal error
    Thread Starter Martin Blumenfeld

    (@monkeypress)

    Thanks so much!

    Plugin Author Sybre Waaijer

    (@cybr)

    @monkeypress No problem!

    Note: the second code block had a missing ' (thus fatal error), I just fixed that. ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Noindex Post Type’ is closed to new replies.