4 techniques needed to improve WordPress's menu bar
QuanTriMang - If you have just upgraded WordPress to version 3.1, it will discover a new point that the system will display WordPress Admin bar for administrators and normal users to log in . If WP Admin Bar was created to provide users with convenience via the links on the top of each page, then this function does not come with any form of customization, has inadvertently affected somewhat that is its usefulness. In the following article, we will introduce 4 basic ways to improve the utility of WP Admin Bar.
1. Remove the links available from WP Admin Bar:
Go to the theme folder, and open the functions.php file with the application to edit any text. Then, add the following code to the end:
add_action ('wp_before_admin_bar_render', 'remove_admin_bar_links');
function remove_admin_bar_links () {
global $ wp_admin_bar;
$ wp_admin_bar-> remove_menu ('comments');
}
The above code will remove the COMMENTS link from the Admin Bar . The operation mechanism is based on the function $ wp_admin_bar-> remove_menu (ID) , by providing the ID of the path to be deleted (in this case the corresponding ID is COMMENTS ), you can completely remove any path from the Admin Bar.
Below is a list of some frequently used IDs and very useful for most of us:
- my-account-with-avatar / my-account: connecting to your account, here the ID parameter depends on whether the user is active or not to display the avatar.
- my-blogs: Sites menu, only works with Network mode.
- edit: link to edit posts or pages.
- new-content: add New menu.
- comments: connect to comments.
- appearance: Appearance menu.
- updates: update the path.
- get-shortlink: create a short path to any page.
2. Assign a custom path to WP Admin Bar:
To add your own links to the Admin bar menu, add the following lines of code in the functions.php file:
add_action ('wp_before_admin_bar_render', 'add_admin_bar_links');
function add_admin_bar_links () {
global $ wp_admin_bar;
$ wp_admin_bar-> add_menu (array (
'id' => 'Google',
'title' => __ ('Google'),
'href' => 'http://google.com'
));
}
According to the above example, we have added Google.com as a new path in Admin Bar, of course it can be adjusted to anything according to your requirements. The parameters to note here are id, title and href:
id: identification point of the path.
title: The name displayed on the Admin Bar.
href: the path address will point to.
For example, you can create submenu using the following code:
add_action ('wp_before_admin_bar_render', 'add_admin_bar_links');
function add_admin_bar_links () {
global $ wp_admin_bar;
$ wp_admin_bar-> add_menu (array (
'id' => 'Google',
'title' => __ ('Google'),
'href' => 'http://google.com'
));
$ wp_admin_bar-> add_menu (array (
'parent' => 'Google',
'id' => 'GoogleAnalytics',
'title' => __ ('Google Analytics'),
'href' => 'http://google.com/analytics'
));
}
The result will look like the image below:
3. Display the login form if the user is not logged in:
By default, the Admin Bar bar is only available for logged-in users. But for some reason, if you want this Admin Bar to always be displayed, and come with login templates if the user is not logged in, use WordPress Admin Bar Improved to enable this feature.
4. Turn off completely Admin Bar:
It sounds unreasonable, but many people want to completely remove this menu bar. Log in to the main WordPress panel and select the Profile tab. Under Show Admin Bar , uncheck chech at when viewing site and print dashboard:
If you are a multi-blog manager (or work in Network mode) and want to turn off the Admin Bar for all authors, add the following line of code in the functions.php file :
add_filter ('show_admin_bar', '__return_false');
Good luck!
You should read it
- WordPress.com blog service collapsed because of a DoS attack
- Adding dynamic widgets to WordPress blogs without using code
- Build a blog with WordPress
- 10 free WordPress plug-ins for bloggers
- Instructions for creating a Wordpress blog page
- 11 security tips for WordPress blogs
- Check spelling in WordPress with After the Deadline
- The guide to turning Blogger into WordPress does not worry about losing Google rankings
May be interested
- How to display the menu bar in Internet Explorer 7in older versions of the browser, the menu bar is displayed by default. you can set up ie7 to display the menu bar with just a few simple steps.
- 3 ways to fix Start Menu on Windows 10 stopped workingstart menu is probably the most popular feature of windows 10. however, for some pc versions, this feature may be corrupted. in this article, tipsmake.com will guide you how to fix start menu errors on windows 10.
- How to pin apps and contacts on Android's Share menuandroid's share menu has changed over the years. now, this feature is more customizable and users can pin frequently used apps and contacts to the top of the list for easy access.
- What is the Power User Menu?power user menu is available by default (you don't have to download it) in windows 10 and windows 8 as a popup menu with shortcuts for managing, configuring and other windows tools.
- How to fix the loss of the New menu in the right-click menuwhen you press the new menu in the right-click menu, you'll add a new folder, or have some other software options. so what if i lose the new option in the right-click menu?
- How to restore the old context menu in Windows 11the context menu (right-click menu) in windows 11 is a major source of frustration for many users. it's slower, requires extra clicks to access familiar options, and is less intuitive than the classic menu.
- How to use the Style Menu on Pixel 4google pixel 4 has brought to the style menu, a special feature that many device users from other brands aspire to. style menu has the ability to easily create device themes.
- Lock Mac OS X screen when neededbut did you know that only a very small screen lock is possible, but do we have 7 ways to do it? please administer the point network through this list.
- The context menu of Windows 11 will have a new eye-catching designcontext menus are an important component of the windows user experience. this menu appears when you right-click on the desktop or applications, drives, or folders.
- Hackers break into WordPress serversan unidentified hacker hacked into the wordpresss server and installed a remote control trojan and download versions of this widely used blog application.