Add or Remove Links to the New WP Admin Bar


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. add
  2. ===
  3.  
  4. function my_admin_bar_link() {
  5. global $wp_admin_bar;
  6. if ( !is_super_admin() || !is_admin_bar_showing() )
  7. return;
  8. $wp_admin_bar->add_menu( array(
  9. 'id' => 'diww',
  10. 'parent' => 'my-blogs',
  11. 'title' => __( 'Title of the link you want to add'),
  12. 'href' => admin_url( 'http://mysitesurl.com/wp-admin.php' )
  13. ) );
  14. }
  15. add_action('admin_bar_menu', 'my_admin_bar_link');
  16.  
  17. remove
  18. ======
  19.  
  20. function remove_admin_bar_links() {
  21. global $wp_admin_bar;
  22. $wp_admin_bar->remove_menu('my-blogs');
  23. $wp_admin_bar->remove_menu('my-account-with-avatar');
  24. }
  25. add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.