Disable All In One SEO Pack for some custom post types [closed]

I have a WordPress site using custom post types, and I have also got the All In One SEO pack installed.

I wondered if anyone knows a hack or a modification I can make to the code which will allow me to stop the pictured area from showing up on certain custom post types?

enter image description here

Any help much appreciated.

2 Answers
2

If you’re satisfied with disabling the SEO-Pack on all CPTs, go with brasoflo’s answer.

Should you want to keep the metabox for some CPTs and disable it only for a select few:

function wpse_55088_remove_aiosp() {
    remove_meta_box( 'aiosp', 'movie', 'advanced' );
}
add_action( 'add_meta_boxes', 'wpse_55088_remove_aiosp' );

Where 'movie' is, going with brasoflo’s answer, the name of the CPT. Repeat the call to remove_meta_box(); for each post type you want to target. If it’s a fairly high number, you could wrap it in a loop:

function wpse_55088_remove_aiosp() {
    $cpts = array( 'movie', 'album', 'clip', 'trailer' );

    foreach( $cpts as $cpt ) {
        remove_meta_box( 'aiosp', $cpt, 'advanced' );
    }
}
add_action( 'add_meta_boxes', 'wpse_55088_remove_aiosp' );

It might sound a bit confusing, that I suggest hooking the function with the 'add_meta_boxes' action when you want to remove one, but this action runs after all meta boxes have been added, hence that’s when existing ones can be removed. If you ran the function too early, the box would get added afterwards.

Leave a Comment