I was trying to customize the admin bar a bit by adding an extra logo, and showing the bar to all users(even non registered ones).

Here's the code from my plugin.

add_filter( 'show_admin_bar', '__return_true' ); 
add_action( 'admin_bar_menu', 'remove_wp_logo', 999 );
add_action( 'admin_bar_menu', 'social_links',11 );

function remove_wp_logo( $wp_admin_bar ) {
    $wp_admin_bar->remove_node( 'wp-logo' );
    if (! current_user_can('administrator')) $wp_admin_bar->remove_node('my-account');

function social_links( $wp_admin_bar){

    $Tlogo = "<img src='http://localhost/wp/wp-content/mu-plugins/d.png'>";
        'id' => 'ds',
        'title' => $Tlogo,
        'href' => 'https://www.twitter.com/',
        'meta' => [
        'target' => 'sitepoint'

So far I'm able to add the links I need but it only appears on desktop, when I resize the window, everything I added disappears from the responsive menu! Even the search bar.

Is there a way to add my icons to the responsive menu too (with the search button as well, if possible)

Thanks in advance.

  • Only a hint, not in case of your question. But you should not use $wp_admin_bar as global. That's the parameter of the hook- So add them to your function social_links($wp_admin_bar). That's more solid. – bueltge Jul 17 at 14:36
  • thx for the hint :) .I modified my function. Do you mind explaining what you actually mean by "more solid"?. I'm aware that using globals isn't the best practice, but do you have a specific reason? Thx again – user206904 Jul 17 at 14:43
  • right - in short ;) – bueltge Jul 18 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.