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!
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.
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 );
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.
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!