WordPress custom links in admin bar


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



Copy this code and paste it in your HTML
  1. // add custom links to admin bar
  2. // via bit.ly/wprec-adminlx
  3.  
  4. function mytheme_admin_bar_render() {
  5. global $wp_admin_bar;
  6. $wp_admin_bar->add_menu( array(
  7. 'parent' => 'new-content', // use 'false' for a root menu, or pass the ID of the parent menu
  8. 'id' => 'new_media', // link ID, defaults to a sanitized title value
  9. 'title' => __('Media'), // link title
  10. 'href' => admin_url( 'media-new.php'), // name of file
  11. 'meta' => false // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' );
  12. ));
  13. }
  14. add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );

URL: http://bit.ly/wprec-adminlx

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.