Hide the Yoast Box on Selected Post Types
Removes the Yoast SEO meta box from post types that never appear in search, such as internal records, while leaving it on everything else.
Opens WPIDE on
Code
// Post types without the Yoast box.
$wpide_yoast_hidden_types = array( 'testimonial', 'faq' );
add_action( 'add_meta_boxes', function ( $post_type ) use ( $wpide_yoast_hidden_types ) {
if ( in_array( $post_type, $wpide_yoast_hidden_types, true ) ) {
remove_meta_box( 'wpseo_meta', $post_type, 'normal' );
}
}, 100 );
Notes
To exclude a post type from Yoast entirely, also set it to "noindex" in Yoast's settings.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.