I’ve managed to remove the filter box and the (4) additional SEO columns. Still struggling to remove the Robots Meta column from posts and pages, as doing an unset on the column doesn’t seem to be working.
Yes I know you can hide this with screen options – but I manage over 50 clients sites and it’s not feasible to go edit all these – especially if additional users are added to the site. I need to use functions in my theme code so I can push out one update.
For anyone else that needs code for your theme functions.php – here is what I have working. There might be a cleaner way to code this, but it’s working for me.
NOTE – I prefix all my functions with ‘xko’ for our company – but you really should change this so that it’s unique to you 🙂
—– Hide the SEO Columns (Score, KW, etc.) —–
This code will remove these additional (4) columns from the posts and page screens, without hacking original plugin code:
function xko_seo_columns_filter( $columns ) {
unset($columns['wpseo-score']);
unset($columns['wpseo-title']);
unset($columns['wpseo-metadesc']);
unset($columns['wpseo-focuskw']);
return $columns;
}
add_filter( 'manage_edit-post_columns', 'xko_seo_columns_filter', 10, 1 );
add_filter( 'manage_edit-page_columns', 'xko_seo_columns_filter', 10, 1 );
If you have additional custom post types, you need to add more filters. I had 6 additional custom post types 🙂
The syntax is like this:
add_filter( 'manage_edit-CUSTOMPOSTTYPE_columns','xko_seo_columns_filter', 10, 1 );
So if your custom post type was ‘book’, the filter would be:
add_filter( 'manage_edit-book_columns', 'xko_seo_columns_filter',10, 1 );
—– Hide the SEO Filter Box —–
I’m using CSS to hide this, but passing it through a function so that you don’t have to go update the CSS file, and I’m already changing the functions.php – so it’s just one change for all my sites. Using an array / in_array function so I can remove from both posts and page (and any custom post types – see below):
function xko_hide_seo_filter_box(){
$my_post_type = array('post','page');
global $post;
if (in_array($post->post_type, $my_post_type)) {
echo '
<style type="text/css">
#posts-filter .tablenav select[name=seo_filter] {
display:none;
}
</style>
';
}
}
add_action('admin_head-edit.php', 'xko_hide_seo_filter_box');
Now, if you have multiple custom post types, you can add them to the array. So to include the custom post type ‘book’ we have:
function xko_hide_seo_filter_box(){
$my_post_type = array('post','page','book');
global $post;
if (in_array($post->post_type, $my_post_type)) {
echo '
<style type="text/css">
#posts-filter .tablenav select[name=seo_filter] {
display:none;
}
</style>
';
}
}
add_action('admin_head-edit.php', 'xko_hide_seo_filter_box');
Hope this helps anyone else looking for a way to hide these without editing the plugin files. If I figure out why the Robots Meta doesn’t want to unset, I’ll come back and post the code.