You might have already updated to the latest WordPress 3.1. This version comes with a handy admin bar that provides signed-in users quick access to some Admin features, directly from the main site.
WordPress has not provided any options to customize this bar, that is, you cannot add or remove any links. But there are still ways to do so by creating functions. Here I will show, how you can customize the Admin bar the way you want.
Add Single Links on the Admin Bar
To add a new custom link on the WordPress admin bar, drop the following function in your theme’s functions.php
file.
function add_sumtips_admin_bar_link() { global $wp_admin_bar; if ( !is_super_admin() || !is_admin_bar_showing() ) return; $wp_admin_bar->add_menu( array( 'id' => 'sumtips_link', 'title' => __( 'SumTips Menu'), 'href' => __('http://sumtips.com'), ) ); } add_action('admin_bar_menu', 'add_sumtips_admin_bar_link',25);
Change the id
, title
and href
value with your own.
Create Link Submenus on the Admin Bar
Now here, we will first create two sub-items (“View All Posts” and “Downloads”) for the link “SumTips Menu.” Then again, add another new link (“Browsers”) as a child item to the “Downloads” menu. This will create a two-level menu on the Admin bar.
function add_sumtips_admin_bar_link() { global $wp_admin_bar; if ( !is_super_admin() || !is_admin_bar_showing() ) return; $wp_admin_bar->add_menu( array( 'id' => 'sumtips_link', 'title' => __( 'SumTips Menu'), 'href' => __('http://sumtips.com'), )); // Add sub menu link "View All Posts" $wp_admin_bar->add_menu( array( 'parent' => 'sumtips_link', 'id' => 'sumtips_all', 'title' => __( 'View All Posts'), 'href' => __('http://sumtips.com/all'), )); // Add sub menu link "Downloads" $wp_admin_bar->add_menu( array( 'parent' => 'sumtips_link', 'id' => 'sumtips_downloads', 'title' => __( 'Downloads'), 'href' => __('http://sumtips.com/downloads'), 'meta' => array( 'class' => 'st_menu_download',), )); $wp_admin_bar->add_menu( array( 'parent' => 'sumtips_downloads', 'id' => 'sumtips_browsers', 'title' => __( 'Browsers'), 'href' => __('http://sumtips.com/downloads?category=3'), )); } add_action('admin_bar_menu', 'add_sumtips_admin_bar_link',25);
You can add more links and submenus by extending this single function as per your needs.
We can also pass parameters to the link items, useful for applying CSS. An example of this can be seen above for “Downloads” link.
Remove Links from the Admin Bar
You can easily remove any and all links that are found by default on the Admin bar. In this example, I have removed the WordPress logo and Updates link.
function remove_admin_bar_links() { global $wp_admin_bar; $wp_admin_bar->remove_menu('wp-logo'); $wp_admin_bar->remove_menu('updates'); } add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );
IDs for other top links:
wp-logo:
WordPress logomy-account
: Links to your account. The ID depends upon if you have avatar enabled or not.site-name
: Site name with other dashboard itemsmy-sites
: My Sites menu, if you have more than one siteget-shortlink
: Shortlink to a page/postedit
: Post/Page/Category/Tag edit linknew-content
: Add New menucomments
: Comments linkupdates
: Updates linksearch
: Search box
Get Delete Link on ‘Posts’ and ‘Page’ Pages
With the following code snippet, you can add a quick-delete button on all posts and pages. Button stays hidden on all other pages of your site.
function admin_bar_delete_option() { global $wp_admin_bar; if ( !is_super_admin() || !is_admin_bar_showing() ) return; $current_object = get_queried_object(); if ( !empty( $current_object->post_type ) && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) && current_user_can( $post_type_object->cap->edit_post, $current_object->ID ) ) { $wp_admin_bar->add_menu( array( 'id' => 'delete', 'title' => __('Delete'), 'href' => get_delete_post_link($current_object->term_id) ) ); } } add_action( 'admin_bar_menu', 'admin_bar_delete_option', 40 );
Move Admin Bar to the Bottom of Page
function move_admin_bar() { echo '<style type="text/css"> body { margin-top: -28px; padding-bottom: 28px; } body.admin-bar #wphead { padding-top: 0; } body.admin-bar #footer { padding-bottom: 28px; } #wpadminbar { top: auto !important; bottom: 0; } #wpadminbar .quicklinks .menupop ul { bottom: 28px; } </style>'; } add_action( 'admin_head', 'move_admin_bar' ); add_action( 'wp_head', 'move_admin_bar' );
That’s all. 🙂
122 thoughts on “Customize WordPress Admin Bar by Adding/Removing Links”
I want to remove the updates link from admin bar. i will try ur code. hope it works
It sure does Mukundan! 🙂
This is terribly helpful – Great job doing such a thorough explanation – Thanks!
I modified it to remove links for users with the editor role by using current_user_can – for example:
if ( !current_user_can( 'editor' ) || !is_admin_bar_showing() )
That’s a nice tip Cas. Hadn’t thought about user roles. 🙂
What file do you add the functions to?
You will find a file named
functions.php
in your theme folder. Add the functions you want to use into that.Got it, thanks!
This is great! Thanks for the snippets. Would you know how to simply rename a menu? My current theme has added an extra menu item with an incredibly long name which I’d like to shorten.
Thanks in advance!
Is there a plugin that will do this instead of having to edit the functions file? If not then how hard would it be to create one?
It’s quite easy to create one! Simply add the functions to a new
.php
file and save it in your plugins folder. From there you can manage it as any other plugin.I guess the theme is using a custom function as well. You could look for this line:
'title' => __( 'Menu Name'),
in your theme’sfunctions.php
file and give it the name you want.That’s clever! My theme’s functions.php was initially empty, but I just had to take a good look at other theme files. Thanks for your reply.
Hy 🙂
I would like to rewrite this class:
WP_Admin_Bar -> render()
FROM:
TO:
How can do it?
Didn’t quite understand what you want to do here. Do you want remove the search and replace it with the text??
yesss 🙂
…
Now I’m using Jquery 😉 to replace HTML content but I wooud like to rewrite that function to insert my php script …
Thanks and sorry for my terrible english ^^
It’s not possible to remove that search option using PHP, but you can hide it by using a simple CSS function.
Ok .. .thanks for your time … 🙂
I replace search form with:
jQuery(document).ready(function(){
jQuery(‘#adminbarsearch-wrap’).html( ‘hallo World!’ );
});
Thanks for that tip. 🙂
I would remove that bar by default for all new users and also automatically.
How do I?
Here you go:
Thanks for this. I’m using the Thesis theme. I didn’t have to mess with functions.php. I added the necessary code to create a new Admin Bar menu to custom-functions.php which is easy to get to from within Worpress:
1) Open the Thesis panel on your WordPress dashboard.
2) Click on Custom File Editor
3) Choose custom-functions.php from the Custom File Editor’s dropdown menu (under the text, “Currently Editing”)
4) Click the button next to the dropdown that says “Edit Selected File”
5) Now, add the custom code and click the Big Ass Save button. Assuming you didn’t screw anything up, the Admin Bar changes immediately. No need to even refresh your screen.
Thanks again,
Alan
PhotoCitizen.com
can I ask you how to add a single top-level link to my admin bar? not sure which part of your example deals with this..
I’d liek to link to a certain .php file that redirects the user somewhere. will call the link: random.
function addLinkMenu( $wp_admin_bar) {
$wp_admin_bar->add_menu( array( 'title' => __( 'Hallo World' ), 'href' => 'http://www.example.com/' ) );
}
add_action( 'admin_bar_menu', 'addLinkMenu', 0 ); //try add_action( 'admin_bar_menu', 'addLinkMenu', 999 );
Like this?
🙂
thx, the 999 pushes it quite far to the right but I will add some css to float it right 🙂
ah, just realized your solution puts it into the .quicklinks section, any chance to put it into the #adminbarsearch-wrap part as I am hiding the search anyway…
and since you guys are quite good at this, what would I insert if I only want to show this particular link to logged in users and another one to other visitors? 😉
oh and here is another one: I’d like to show my favicon next to a certain link, like it happens with this item: wp-admin-bar-my-account-with-avatar – you notice its showing the avatar, I’d like to show a link to not logged in users with my favicon next to the link…
any hints?
sorry to be such a pest but this is the best how-to site I could find dealing with the new admin bar 🙂
A) Sorry for my terrible english 😀
B) to put your link on the right of search form is to use jquery, try this:
arrMenuDx = ”;
arrMenuDx+= ”;
arrMenuDx+= ‘ Link al sito 1’;
arrMenuDx+= ‘ Link al sito 2’;
arrMenuDx+= ‘ Link al sito 3’;
arrMenuDx+= ”;
arrMenuDx+= ”;
jQuery(document).ready(function(){
jQuery(‘#adminbarsearch-wrap’).prepend( arrMenuDx );
jQuery(‘#quicklinks-network’).show();
});
Sorry:
A) Sorry for my terrible english :D
B) to put your link on the right of search form is to use jquery
arrMenuDx = '';
arrMenuDx+= '';
arrMenuDx+= ' Link al sito 1';
arrMenuDx+= ' Link al sito 2';
arrMenuDx+= ' Link al sito 3';
arrMenuDx+= '';
arrMenuDx+= '';
jQuery(document).ready(function(){
jQuery('#adminbarsearch-wrap').prepend( arrMenuDx );
jQuery('#quicklinks-network').show();
});
Repalce[] with
arrMenuDx = ‘[div class=”quicklinks” id=”admin-bar-menu-dx”]’;
arrMenuDx+= ‘[ul]’;
arrMenuDx+= ‘ [li id=”sit1″]Link al sito 1[/li]’;
arrMenuDx+= ‘ [li id=”sit2″]Link al sito 2[/li]’;
arrMenuDx+= ‘ [li id=”sit3″]Link al sito 3[/li]’;
arrMenuDx+= ‘[/ul]’;
arrMenuDx+= ‘[div]’;
jQuery(document).ready(function(){
jQuery(‘#adminbarsearch-wrap’).prepend( arrMenuDx );
jQuery(‘#quicklinks-network’).show();
});
this is to view admin bar for all:
add_filter( 'show_admin_bar', '__return_true' , 1000 );
this is for remove link:
if($wp_admin_bar->menu->{'my-account'}) $wp_admin_bar->remove_menu('my-account');
if($wp_admin_bar->menu->{'my-account-with-avatar'}) $wp_admin_bar->remove_menu('my-account-with-avatar');
To view id name try this:
function TEST_FUNCTION( $wp_admin_bar) {
var_dump($wp_admin_bar);
}
add_action( 'admin_bar_menu', 'TEST_FUNCTION',999 );
And now this is my function:
function TEST_FUNCTION( $wp_admin_bar) {
global $user_identity;
$user_id = get_current_user_id();
if ( !is_user_logged_in() ){
$wp_admin_bar->add_menu( array( 'title' => __( 'Log In' ), 'href' => wp_login_url() ) );
$wp_admin_bar->add_menu( array( 'title' => __( 'Registrati' ), 'href' => home_url().'/registrazione/' ) );
} else {
$user_info = get_userdata($user_id);
if(is_user_logged_in() && !$user_info->user_level) {
//Rimuovo la voce di menu utente attuali
if($wp_admin_bar->menu->{'my-account'}) $wp_admin_bar->remove_menu('my-account');
if($wp_admin_bar->menu->{'my-account-with-avatar'}) $wp_admin_bar->remove_menu('my-account-with-avatar');
//aggiungo i miei link personalizzati
if ( 0 != $user_id ) {
$avatar = get_avatar( get_current_user_id(), 16 );
$id = ( ! empty( $avatar ) ) ? 'my-account-with-avatar' : 'my-account';
$wp_admin_bar->add_menu( array( 'id' => $id, 'title' => $avatar . $user_identity, 'href' => home_url().'/profilo/' ) );
$wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Profilo' ), 'href' => home_url().'/profilo/' ) );
$wp_admin_bar->add_menu( array( 'parent' => $id, 'title' => __( 'Log Out' ), 'href' => wp_logout_url() ) );
}
}
}
}
add_action( 'admin_bar_menu', 'TEST_FUNCTION',999 );
I spend much time to do this …
This is not so clean solution but is the only one 🙂
thanks for all that feedback. I am trying to do this as follows:
using a plugin called WordPress Admin Bar Improved that displays the admin bar for logged out users and inserts a login form.
now I was using a php script I inserted in mu-plugins to activate this on all blgos of my multisite installation.
I’ll sum up my questions to make it easier:
– not sure how to proceed with the jquery stuff… can it go into my plugin?
– need to show a certain link on the left and another one on the right. solved the üart where it shows to everyone already
see screen shots of what I am trying to achieve here: http://screencast.com/t/H8d16XgdVup and http://screencast.com/t/x5urBnlglQn
here is what I have so far: http://pastebin.com/SD9pAJt2
btw. the test URL is this, check it out live: http://zice.ro
– I use Jquery for only add a new menu on the right of search form
– What you think about to create a new toolbar .. disable admin bar and create a new your toolbar … ?
hm… is a new toolbar really easier? I don’t think it should be this complicated to position things withinthe admin bar…. will continue playing a round for a few more days…
With adminbar I found that you can only add/remove new li elment (link and title) in ul tag and with jquery copy an html content for build login form … for other things … 🙁 I don’t know …
Create new toolbar …
You can grab avatar with:
$avatar = get_avatar( get_current_user_id(), 16 );
$id = ( ! empty( $avatar ) ) ? 'my-account-with-avatar' : 'my-account';
For user level
global $user_identity;
$user_info->user_level
is_user_logged_in()
and so on …
How can I remove a plugin link that is in my Admin Bar..The SEO plugin from Yoast adds into the admin bar..I want to remove it? Any help would be awseome!
Another thing? How would I have my subscribers also see my custom menu I created? Works great I just need members to see,,,thanks…
how could I add the admin bar on top of my bbpress installation? I have it integrated with wp multisite and I’d like to keep the same look…
whats the call to call the admin bar inside the theme header.php of my bbpress template?
another one:
I’d liek to add a link under the menu: comments.
on its own it works but it simply doesn’t let me place it underneath the comments menu:
` function addNetworkComments($wp_admin_bar) {
if ( is_user_logged_in() ){
$wp_admin_bar->add_menu( array( ‘title’ => __( ‘Discutiile mele’),
‘href’ => admin_url( ‘index.php?page=my_network_comments’ )
) );
}}
add_action(‘admin_bar_menu’, ‘addNetworkComments’, 0);`
on witch file i made all these changes i guess i miss it out..
ty
You need to make changes to a file named
functions.php
, found in your theme folder. If it doesn’t exist, create one.Hello, thanks for share this code..
I’ll try it 🙂
Hi! This works great! I am using the code “Remove Links from the Admin Bar”. I want to remove the “page” and the “categories” edit, but can’t find the ID. Any help!?? Thanks!
Hi Paulo, “edit” is the common id for editing post, pages, categories, and tags. To remove those links, you can use the following:
Thanks for this tutorial!
I have built a show/hide panel for my theme that offers user a way to login and when logged in, to have links like the admin bar. Currently all those links are added “manually” using simple html (and if statements to see the user level, .etc)
I have searched and searched and all the tutorials only offer a way to move the admin bar to the bottom of the page. I want to move (or call) the admin bar into my show/hide panel. Is this possible?
Any help would be greatly appreciated.
Kalman
Thanks for the article, but how would one remove the ‘Dashboard’ link from the admin bar only?
Thanks!
You can remove the ‘Dashboard’ link with this:
Thanks very much Renji 🙂 This worked perfectly!
There are so many great nuggets in the article. Have you thought about turning your code into a plugin that allows admins to completely customize the nav bar depending on user roles?
This code below adds links to the administrator’s account but how do I add links to the subscribers pages?
function my_admin_bar_menu() {
global $wp_admin_bar;
if ( !is_super_admin() || !is_admin_bar_showing() )
return;
$wp_admin_bar->add_menu( array(
'id' => 'custom_menu',
'title' => __( '会員ページ'),
'href' => FALSE ) );
$wp_admin_bar->add_menu( array(
'parent' => 'custom_menu',
'title' => __( 'A4JPデザイングループ'),
'href' => 'http://a4jp.com/' ) );
}
add_action('admin_bar_menu', 'my_admin_bar_menu');
Thanks in advance for this!
My question is this: Somehow, the edit page or post is missing from the admim bar.
For example, I used to be able to be on a page and if I’m logged in, I can choose to edit the page/post from the top admin bar.
It’s basically just turned off of the Top Admin Bar and I can’t figure out how to turn it back on?
I have done it and it works for all the browsers, except Internet Explorer (I am testing on the version 9)
Have you got any idea about what to do?
It does work on IE. Tested.
Sorry for the late reply. See if you have this
$wp_admin_bar->remove_menu('edit');
in your functions file. That code removes those links.Really appreciate the personal support! I check in my themes functions.php and that’s not in there.
In the wp-includes/admin-bar.php I see the code for it:
function wp_admin_bar_edit_menu( $wp_admin_bar ) {
(snip)
I’m just so perplexed how it disappeared!
Even I am perplexed now. 😉
Joke apart, I am not able to figure out what might be causing this issue for you. Perhaps some other code or plugin might be doing it. If you don’t think so, then try updating your WP installation and see if that helps.
Yeah, updated to latest version of everything, but the Edit menu is still gone!
Thanks for even putting some energy into this. If you think of anything, lemme know. Our site is at EC Simplified
Excellent tutorial! Thanks for taking the time to share this with us. It made my life much simpler (by reducing several hours of work!). Cheers.
Thank you for this!
By default, WordPress displays shortlinks in the admin bar for posts but not pages.
How can I add Get Shortlink to the admin bar for pages? Thanks!
Hey Chris,
To that first remove the existing ‘Shortlink’ link from the admin bar. Method shown above. Then add a new ‘Shortlink’ link with the following code:
New link will be visible on all posts and pages.
Renji,
Thanks for this. I was able to successfully remove and add my own Shortlinks menu link. Works fine for posts; menu item displays correctly for pages, but shortlink does not work for pages. Appears to be a shortcoming of the wp_get_shortlink() function.
http://core.trac.wordpress.org/ticket/14760
Bigger project than I anticipated!
My site is multi user. I need to hide some wp admin bar elements, and Renji shows me how. Thanks man.
Is it possible to add a container element to the menu, one that has children, but that itself isn’t a link? I tried sending empty href’s to add_menu, etc, but it always seems to render it as a link that just refreshes the page.
Thoughts?
Bah – just answered my own question!
[…]
‘href’ => “#”,
‘meta’ => array (
‘onclick’ => “return false;”
),
[…]
Thanks for this! It was super helpful!
That was cool. Never thought it could be possible but thanks a lot. You did such a great help.
I’ve got the same problem…
I have it visible on my local MAMP install, but on my live server the “edit page” has disappeared. In fact it has replaced “edit page” with “edit categories”….?!?!
I don’t have any plugins.
The only thing that I think may be happening is that my live site is sitting in a virtual directory on the server (http://site.com/~USERNAME) – maybe WP can’t resolve the path to the page, so it just removes the option altogether…
Yeah, mine is still broke. The theme developer say it’s WP or a Plugin, but I didn’t add any plugins. I moved some content around and a few small items and it’s gone. WordPress says it’s the theme and there’s no one with the expertise to track down the problem of Edit Page falling off the Menu.
Hey Renji,
Do you think there’s a way to re-add the Edit Current Page or Post using the new plugin Custom Admin-Bar Favorites?
Guys, see if any of these work for you:
or
@Saki Post edit links are dynamically generated by WordPress. Since that plugin allows only static URLs, it may not satisfy what you want.
I noticed with adding a link to the admin bar it shows up all the way to the right hand side of the admin bar, Im trying to place the links all the way to the left hand side. Any ideas on how to fix that?
Im sorry,
– Error in last post –
Links are showing on the Left hand side,
I want to place them in the Right hand side ******
Wow! This could be one of the most helpful blogs we have ever come across on thesubject. Actually great post! I’m also an expert in this topic therefore I can understand your effort.
Thanks for this tutorial, saved me some time at work coding it in for a client!
Cheers
Big G
Hey,
I’m trying to remove the “post” option under “Add new” in the admin bar for the user class Author, but i can’t seem to make it work. Any chance you can fix me up with some code that can fix the problem?
Cheers
Theis
Hi Theis,
You cannot remove only the “Post” option using any of the code shown above. To hide that you can use this:
But do note that the post editor is still accessible via direct link and also from the dashboard menu. Authors, by default, have the permission to create and publish posts.
Thank you for your fast reply! 🙂 I’ll give it a try.
Anyway to get rid of the Visit site under the Site Name but not the Site name? Seems redundant.
– Thanks
Yes. Here’s the code for that:
Thank you!
Thank you so much for that! I’m writing a plugin to get all my clients websites in order and I wanted to display links some information about myself. Cheers!
these steps are not working for me. copy pasted the code to remove wp-logo in my theme functions.php.
I am using wp 3.3.
too soon. this works perfectly fine. thanks
Thanks for this. How can I add a logo to the left of the Admin bar, and how can I change the background color on it from grey to my own? Thanks.
You mean, your logo in place of the WordPress logo? That can be done be editing admin bar CSS. As for the background color, this plugin might help you out with the customizations- http://wordpress.org/extend/plugins/blue-admin-bar/
This tut was very helpful ! Thanks alot!
But I need some help . I added a single link to the admin bar , but it is placed all the way to the left. I want it to show right next to the admin bar search (right) .
How can I do this ?
VERY handy! Thank!!!
Hey Guys!
I need some help with some specific admin bar customizations…
Let me explain how I need that.
I’m running buddypress, and the modifications I need to do is for the buddypress admin bar gets Facebook/G+ functions style.
I changed the default buddypress admin bar to wordpress 3.3 admin bar, that’s really cool, but as I said, I need some customizations else…
Well, I’m going to put the admin bar tabs one below the other, but please, imagine a horizontally:
PS: To do the modifications below I need to increase the admin bar hight like facebook’s bar.
———————————————
WP-LOGO TAB: I need to change this logo for one of the same size and shape, like a little ball, but the drop down menu I want to change to my network “Privacy Politics” instead of WP informations.
———————————————
MY SITE LOGO: Just linking to the homepage, no dropdown menu is necessary.
———————————————
WP-ACTUALIZATIONS LOGO: I want this nice logo to display the user’s notifications instead the written tab, and the dropdown menu just like it is when the user put the mouse coursor on the tab, in fact the only modification is changing the tab from written to a logo with the same notifications counter and dropdown.
———————————————
Blank Space
———————————————
CENTRAL SEARCH BAR: I need a central search bar with buddypress options to search members, groups, foruns and blogs. I need this search bar in the same size of facebook’s central search bar.
———————————————
Blank Space
———————————————
USER-ACCOUNT WITH AVATAR: The same user account with avatar, but just with a little bit bigger avatar and the same drop down menu.
———————————————
Just this, summarizing the customizations I need to do is increase the admin bar hight;
Just change the wp logo to a same size and shape logo, and change the drop down menu;
After insert my website logo just linking to homepage, with no drop down.
Change the default notifications tab to the actualization logo (those two circular arrows) and the notifications counter, and use the default drop down menu.
After a little blank space insert a Central Search Bar with the dropdown of buddypress search options to “Members, Groups, Foruns and Blogs”.
And again after a blank space the My Account options just like it is for default, and just increase a little bit the user’s avatar size.
And for the final, remove that default wp search button on the right.
Anyone could help me with this customizations? I’m a begginer in php codes and I’m having a lot of difficult to do this things…
Thanks guys!
Derek
hello
Thanks, and I was very helpful 🙂
I wanted to ask a little favor could not put the bar down?
another thing how do I display the bar even if you are not logged in?
thanks
more
Hi Luca,
The code shown in post is working fine to put the bar at the bottom of page. See it you copy-pasted it correctly.
To display the toolbar while you are logged out, add any of these codes to your
functions.php
file:OR
with the response, the bar is always displayed in the other, and not down.
I want to know how to add buttons to the toolbar, even as you are not logged in or no admin users
you do not you tell me where is the bar “files” where can I change
hello
one other thing I like a menu for a user is not logged in?
Does anyone know how I can position a toolbar node/menuitem on the right hand side of the toolbar, next to ‘howdy’?
I can only find out how to float them from the left hand side,
Thanks, Philip
Great Post! I was looking for this. Thanks!
Cheers Twana
in the line that says
add_action(‘admin_bar_menu’, ‘add_sumtips_admin_bar_link’,25);
change the number from 25 to 10, 20, 30, 500, etc for positioning in menu.
Hi Renji,
Noticed your instructions say function.php instead of functions.php under “Add Single Links on the Admin Bar”. Thanks for sharing your work.
How about just to make the wpadminbar position not fixed, so the bar scrolls with the page?
And to make it read my CSS?
Thanks!
Thanks buddy! I am searching this wordpress tricks for so many days. I wanted to edit my admin bar for adding some link,but i can’t find any useful post like this. This tricks is very easy do noob like me! thanks again 😛
Thank you! this is very helpfull. i`ve been search this tutorials for long time ago. thank you for sharing… 😀
Hi, Thanks for this great tutorial! I’m wondering if there is a way to add a link in the navbar that BOTH site admins and users can see.
As it is in your code now, only admin’s can see the new link. I am hoping that users of the BB press forum installed on my site could also see the link in their navbar when they sign in.
Is that possible? Any help would be greatly appreciated!
Thanks
Thank you! Made the changes. 🙂
Hi Seth,
As WordPress toolbar is shown only to logged in users, you’d have to first make it public. Then to show the link to logged out users, an additional condition is required. The below code would do both:
P.S. I haven’t tested the code with BBpress, but it should work on a standard WordPress setup.
Hi Renji,
Thanks very much for the fast reply. I think I didn’t explain what I meant very well, here’s another attempt at clarity:
I want registered wordpress users (subscribers, forum participants, authors, etc.) of the site to be able to see the button in the navbar, right now only admins of the site can see it.
Does that make sense?
Thanks again for your help.
Best,
Seth
Yes, got it now!
This code will add a link that is visible to all registered users:
You can further fine tune link visibility based on user roles. This posts should help you with that: http://codex.wordpress.org/Roles_and_Capabilities
This did it. Thanks so much!
-Seth
Hi Renji,
Great post and very useful code. I apologize if this has been covered by I can’t seem to find it – how do I show the menu/submenu for those with a specific capability? Alternatively, how do I show the menu/submenu for those with admin, editor, and author roles?
Regards and thanks,
John
Very nice codes wow, thank you.
I just can’t figur out how to hide displaying the =>Dashboard<= access (front-end) for subscribers, contributer and not logged in users. The site-name should stay as kinda "home" btn.
To prevent access for them I used following code:
function prevent_admin_access() {
if (strpos(strtolower($_SERVER['REQUEST_URI']), '/wp-admin') !== false && !current_user_can('level_2' )) {
wp_redirect(get_option('home'));
}
}
add_action('init', 'prevent_admin_access', 0);
A hint or solution would be nice.
Thnx in advance for time and effort.
This is a great tip particularly to those new to the blogosphere.
Brief but very precise info Thank you for sharing this
one. A must read post!
I ended up this blog a few weeks back and I seriously can’t get enough! Please keep writing!
Admiring the persistence you put into your website and in depth information you
present. It’s nice to come across a blog every once in a while that isn’t the same old rehashed information.
Great read! I’ve saved your site and I’m adding your RSS feeds to my
Google account.
Thank you for this great article. This was just what I needed to see 🙂
Hey there, I think your site might be having browser compatibility
issues. When I look at your website in Firefox,
it looks fine but when opening in Internet Explorer, it has
some overlapping. I just wanted to give you a quick heads up!
Other then that, superb blog!
Tried, but this code doesn’t work on Multisite or the latest version of WordPress.