Skip to content

Instantly share code, notes, and snippets.

@thagxt
Last active September 18, 2022 20:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thagxt/dd516468af7598ae8e3c to your computer and use it in GitHub Desktop.
Save thagxt/dd516468af7598ae8e3c to your computer and use it in GitHub Desktop.
Add a custom url in the Wordprss Admin bar!
<?php // copy & paste the code below in your functions.php file, change the title and href and save it.
function add_link_to_adminbar($wp_admin_bar){
$args = array(
'id' => 'custom-link',
'title' => 'Custom Button Title',
'href' => 'http://example.org/',
'meta' => array(
'class' => 'custom-link-class'
)
);
$wp_admin_bar->add_node($args);
}
add_action('admin_bar_menu', 'add_link_to_adminbar', 50); // change the number 50 if you want to change the link location, with 999 the link goes last. 10 or empty link goes first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment