WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Remove theme options link from admin bar (7 posts)

  1. pjbursnall
    Member
    Posted 7 months ago #

    Hi,

    I am customising an admin panel for a client, using the AG Custom Admin plugin. The only thing I can't disable is the theme options link which sits to the left of 'New' link (for post, media, page) on the admin bar. How can I hide this?

    I know I could disable the admin bar but I'd rather just remove the theme options link.

    Thanks,
    Paul.

  2. bcworkz
    Member
    Posted 7 months ago #

    Use the remove_node() method of the WP_Admin_Bar object.

  3. pjbursnall
    Member
    Posted 7 months ago #

    Thanks for the advice, maybe I haven't got it quite right though. I've added this to the theme functions.php but the link still remains:

    add_action( 'admin_bar_menu', 'remove_customer_support', 999 );
    
    function remove_customer_support( $wp_admin_bar ) {
    	$wp_admin_bar->remove_node( 'customer_support' );
    }

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    I've tested the same with site-name and it works so I'm not sure what I've got wrong?

    Thanks,
    Paul.

  4. bcworkz
    Member
    Posted 7 months ago #

    That snippet should work for you AFAICT. Some possible avenues of investigation: You could try a var_dump of $wp_admin_bar->nodes to ensure you've got the ID right. You may need to die() afterwards to see the dump. If it's not in that array, it somehow managed to get added after your callback is run. Find the code that adds it and figure out why.

    There could be some sort of conflict with one of your plugins. Try disabling them and see if the node is then removed. That's about the only things I can think of that would cause failure.

  5. pjbursnall
    Member
    Posted 7 months ago #

    I'll try disabling plugins, then update. The node id is definitely correct, I've confirmed that earlier...

    Thanks.

  6. pjbursnall
    Member
    Posted 7 months ago #

    No, even with all plugins deactivated 'theme options' remains in the toolbar. WP can be incredibly frustrating at times when considering how things look from a clients point of view.

    Paul.

  7. pjbursnall
    Member
    Posted 7 months ago #

    Ah, solved! And I could of done it much earlier. The code that added the link was in the function.php file already. Commented out now and the link is gone :)

    Thanks for your help,
    Paul.

Reply

You must log in to post.

About this Topic