WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
[resolved] Columns, Filters & Additions to Admin Bar - need to remove (7 posts)

  1. housebg
    Member
    Posted 2 years ago #

    Hi Joost,

    I love this plugin, but I'm having problems using it on my client's sites because of all the new features that are added automatically. Specifically, all the columns added, the SEO filter added and the SEO links added to the Admin bar.

    I don't mind seeing this as the admin, but I must be able to remove this for Editors and below on my client's sites. And i really don't want to keep hacking core files for this.

    How can I remove all these, with a function filter maybe? Something?

    Thanks in advance

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. housebg
    Member
    Posted 2 years ago #

    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.

  3. Joost de Valk
    Member
    Plugin Author

    Posted 2 years ago #

    Ehm mate, there's one filter line that does all of this for you :P

    Check here:

    http://yoast.com/wordpress/seo/api-docs/#filters

    under backend, just return false on wpseo_use_page_analysis.

  4. housebg
    Member
    Posted 2 years ago #

    Oh sure, give me the easy way out :-)
    Works perfect thanks - I guess at least I learned something doing it the hard way.

    For the Robots Meta column, I've got it narrowed down to a problem with the Codepress Admin Columns. With that activated, the Robots Meta column is displayed but doesn't show up in the plugin to remove.

    I've posted this with the Admin Columns plugin author - so hopefully he can figure out what's going on.

    Thanks again!

  5. stemie
    Member
    Posted 2 years ago #

    When I use add_filter( 'wpseo_use_page_analysis', '__return_false' ); it just puts the seo columns at the end it doesn't remove them?

    Any ideas what Im doing wrong?

    I also have the codepress admin columns problem.

  6. Tobias Schutter
    Member
    Posted 1 year ago #

    I have updated Codepress Admin Columns to version 1.4.6.

    It should give you the option to show/hide/re-order/re-label any column that is placed by WordPress SEO by Yoast.

    Explanation
    WordPress SEO checks which page is being viewed before it loads it's column headings ( through WPSEO_Metabox ). The columns headings weren't being displayed, because my plugin loads a settings page instead of a overview page. So I added a fix specially for WordPress SEO which now does display the column headings.

  7. Robert Dall
    Member
    Posted 1 year ago #

    Hey @housebg

    I actually used your code but I added a conditional statement so it only effects authors and below.

    I have a gist here
    https://gist.github.com/4645418

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.