Support » Fixing WordPress » Don't forget to set hook priority when adding links to the new admin bar

  • Resolved Carl

    (@carlthome)


    After struggling for a while with adding custom links to the admin bar for my custom theme-options pages I finally found the error.

    Apparently for existing parents, such as Appearance, Add new and Updates, it’s critical to declare a priority for the hook.

    This won’t work:
    add_action('admin_bar_menu', 'modify_admin_bar');

    This will work:
    add_action('admin_bar_menu', 'modify_admin_bar', 99);

    Notice the third function argument. It doesn’t make a difference which number you choose as long as it is defined.

    In the future I’m hoping the admin bar automatically adds custom sub-pages like the admin sidebar navigation does.

    Anyway, good to know.

  • The topic ‘Don't forget to set hook priority when adding links to the new admin bar’ is closed to new replies.