Change WordPress user roles and capabilities Forums How to or FAQ How to block/hide items from the top bar of wordpress?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3316
    pazazta
    Participant

    I have in the top bar of items that I want to remove such as “Yoast SEO”.
    I want to remove it only from the top and keep it on the regular menu

    #3318
    Vladimir
    Keymaster

    In general, top admin menu bar menu is blocked automatically if its correspondent main admin menu item was blocked.

    In order to block “Yoas SEO” just at top admin menu bar use this code:

    
    add_action('wp_before_admin_bar_render', 'block_top_wp_seo');
    
    function block_top_wp_seo() {
        global $wp_admin_bar;
        
        if (current_user_can('administrator')) {
            return;
        }
        
        $wp_admin_bar->remove_menu('wpseo-menu');
    
    }
    
    

    Insert into the active theme functions.php file for the single site or setup as a “must use” plugin to aplly it globally to all sites.

    https://codex.wordpress.org/Must_Use_Plugins

    #3320
    pazazta
    Participant

    Great thank you!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.