Support » Plugin: The SEO Framework – Fast, Automated, Effortless. » How to exclude Posts and Categories

  • Resolved blackeye0013

    (@blackeye0013)


    Hello,

    I know I shouln’t do this unless I know what I’m doing, but – is there a way I could exclude default WP Posts and it’s default Category?

    In my specific case, I want to use the categories only for internal classification and I dont want to list their archives and index them. I also don’t want to have the SEO metabox in the category detail (for the sake of simplicity and to prevent user’s confusion).

    Is it possible somehow?

    Thanks

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

    (@cybr)

    Hello!

    I think you shouldn’t be looking at “Exclusions,” but at the “Robots Meta Settings,” a little further down. The “noindex” settings are likely what you need.

    I hope I read your comment correctly. Please follow up if I didn’t. Cheers!

    Thread Starter blackeye0013

    (@blackeye0013)

    Hello Sybre,

    Thanks for your reply. Technically you’re right, I also thought I don’t need to use Exclusions and use noindex instead. But I tried it and it didn’t removed the TSF SEO “metabox” from the Category settings. Since I don’t want to index them, there’s no reason to show them.

    I thought that the Exlusion is one level higher and could remove all the SEO settings completely. I can understand why there is no possibility to use Exclude to Posts and Pages for a regular user, but I think it would be nice to be able to unlock this option in some advanced setting or via filter.

    Thanks.

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi again!

    If you “exclude” a post type, you’ll remove all SEO by TSF from it. This includes all “noindex” you might wish it to output, as well.

    The exclusions are actually meant for misconfigured post types only. I added this restriction to convey that — the native post types are always correct.

    In any case, you can use this to impose an exclusion on the post type “post” only on the administrative interface:

    add_action( 'admin_init', function() {
    	add_filter( 'the_seo_framework_public_post_types', function( $post_types ) {
    		return array_diff( $post_types, [ 'post' ] );
    	} );
    }, 0 );
    Thread Starter blackeye0013

    (@blackeye0013)

    Thanks for your explanation, the noindex part makes lot of sense.

    Your code seems to be almost what I needed, except I needed to remove SEO metabox only from the categories, not the posts themselves.

    Is this the right filter and code?

    add_action( 'admin_init', function() {
    	add_filter( 'the_seo_framework_public_taxonomies', function( $taxonomies ) {
    		return array_diff( $taxonomies, [ 'category' ] );
    	} );
    }, 0 );

    Thanks again.

    Plugin Author Sybre Waaijer

    (@cybr)

    Yes, that looks excellent to me!

    Come to think of it… a more straightforward filter would be the_seo_framework_supported_taxonomy, e.g.:

    add_action( 'admin_init', function() {
    	add_filter( 'the_seo_framework_supported_taxonomy', function( $supported, $taxonomy ) {
    		if ( 'category' === $taxonomy ) return false;
    		return $supported;
    	}, 10, 2 );
    }, 0 );

    The choice is entirely up to you — the result should be the same.

    Have a nice day!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to exclude Posts and Categories’ is closed to new replies.