Removing filter dropdown in posts table (in this case Yoast SEO)

These additional dropdowns are added via the restrict_manage_posts action hook. This means the dropdown output isn’t filterable, but you can remove the hooked action from Yoast SEO.

The filter dropdown is added by the posts_filter_dropdown() method in the WPSEO_Metabox class. It’s added in the setup_page_analysis() method of the same class, which is hooked into admin_init at priority 10.

So, we want to remove that action to prevent the dropdown from being displayed. To do so, we can simply hook into admin_init at a priority greater than 10 (to ensure Yoast SEO has already called add_action()). Yoast SEO stores the WPSEO_Metabox class instance in the global variable $wpseo_metabox, so we can easily access it:

add_action( 'admin_init', 'wpse151723_remove_yoast_seo_posts_filter', 20 );

function wpse151723_remove_yoast_seo_posts_filter() {
    global $wpseo_metabox;

    if ( $wpseo_metabox ) {
        remove_action( 'restrict_manage_posts', array( $wpseo_metabox, 'posts_filter_dropdown' ) );
    }
}

Leave a Comment