Last active
September 18, 2022 20:42
-
-
Save thagxt/dd516468af7598ae8e3c to your computer and use it in GitHub Desktop.
Add a custom url in the Wordprss Admin bar!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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