A true sign of a great CMS to any developer is its ability to be hacked, hooked, and otherwise customized to meet the needs of any situation. A couple that come to mind are WordPress and Drupal, but since this post is about the best WordPress admin page hacks we will stick with WordPress.
Much can be said for the WordPress Codex, and it can be a great resource for aspiring developers. I highly encourage you to familiarize yourself with it before jumping in to hacking the WordPress admin page. Also, just a tip on development, never use code you found on the internet on a live website. Test it first on a development server before taking it live. There, I saved you a lifetime of headaches. You’re welcome.
1. How to Disable Dragging of Metaboxes in the Admin panel
To stop users from dragging metaboxes around the admin area and dashboard just add the following code in your to functions.php
in your theme folder.
function disable_drag_metabox() { wp_deregister_script('postbox'); } add_action( 'admin_init', 'disable_drag_metabox' );
2. How to Show the Admin Bar for Only Admins
Adding the following code into your theme’s functions.php file will only allow admins to see the admin bar, great for those looking to customize the look of the front end while users are logged in.
if (!current_user_can('manage_options')) { add_filter('show_admin_bar', '__return_false'); }
3. How to Remove Menu Items from top Admin Bar
Say you want to keep the top navigation bar but only want to show the links that matter to you, this hack will remove the menu items you don’t want appearing. Go to functions.php
in your theme folder and add following code.
function wps_admin_bar() { global $wp_admin_bar; $wp_admin_bar->remove_menu('wp-logo'); $wp_admin_bar->remove_menu('about'); $wp_admin_bar->remove_menu('wporg'); $wp_admin_bar->remove_menu('documentation'); $wp_admin_bar->remove_menu('support-forums'); $wp_admin_bar->remove_menu('feedback'); $wp_admin_bar->remove_menu('view-site'); } add_action( 'wp_before_admin_bar_render', 'wps_admin_bar' );
4. How to Replace “Howdy, admin” greeting in WordPress admin bar
We understand that silly works, but sometimes its context can be out of place on professional websites. That is why this hack comes in handy. It allows you to remove the “Howdy,” greeting and replace it with something more professional. The following code needs to be dropped into your theme’s functions.php file.
function replace_howdy( $wp_admin_bar ) { $my_account=$wp_admin_bar->get_node('my-account'); $newtitle = str_replace( 'Howdy,', 'Logged in as', $my_account->title ); $wp_admin_bar->add_node( array( 'id' => 'my-account', 'title' => $newtitle, ) ); } add_filter( 'admin_bar_menu', 'replace_howdy',25 );
5. Hide Help link in WordPress panel bar
It’s great to get help, but I consider any link in the back end that takes the user away from the website is usually confusing and bad UX. Most of the time the help link is unnecessary for clients, so to remove it just add the following code to your functions.php file.
function hide_help() { echo ''; }
add_action('admin_head', 'hide_help');
6. Change “Howdy, admin” in WP Admin bar
It’s cute, but in the professional corporate world you might not want to display this to client Just place this code into your theme’s functions.php file.
function replace_howdy( $wp_admin_bar ) { $my_account=$wp_admin_bar->get_node('my-account'); $newtitle = str_replace( 'Howdy,', 'Logged in as', $my_account->title ); $wp_admin_bar->add_node( array( 'id' => 'my-account', 'title' => $newtitle, ) ); } add_filter( 'admin_bar_menu', 'replace_howdy',25 );
7. How to Add New Menu Links to the WordPress Admin Bar
Add following code to your theme’s functions.php and you can easily able to add new items to admin bar.
function wp_admin_bar_new_item() { global $wp_admin_bar; $wp_admin_bar->add_menu(array( 'id' => 'wp-admin-bar-new-item', 'title' => __('SEO Blog'), 'href' => 'http://www.drumbeatmarketing.net/seo-blog' )); } add_action('wp_before_admin_bar_render', 'wp_admin_bar_new_item');
8. How to remove menu items from WordPress admin panel/dashboard
WordPress admin panel comes with a lot of options in the left side menu, but you can get rid of them easily if required. This hack gives you flexibility to remove the menu items from the admin panel.
add_action( 'admin_menu', 'remove_links_menu' ); function remove_links_menu() { remove_menu_page('index.php'); // Dashboard remove_menu_page('edit.php'); // Posts remove_menu_page('upload.php'); // Media remove_menu_page('link-manager.php'); // Links remove_menu_page('edit.php?post_type=page'); // Pages remove_menu_page('edit-comments.php'); // Comments remove_menu_page('themes.php'); // Appearance remove_menu_page('plugins.php'); // Plugins remove_menu_page('users.php'); // Users remove_menu_page('tools.php'); // Tools remove_menu_page('options-general.php'); // Settings }
9. Change footer text in WordPress admin panel
Adding this code in your theme’s functions.php will change the footer text to anything you like it to be. Just change the “My Custom footer text” string with your choice.
function remove_footer_admin () { echo 'My Custom footer text.'; } add_filter('admin_footer_text', 'remove_footer_admin');
10. How to add custom pointers in WordPress admin area
Adding following code in your theme’s functions.php file will allow you to add pointer within your admin area.
Don’t forget to put the desired label and message on line 8 & 9.
Also update the ID with jquery to assign the pointer in place of #menu-appearance in line 14. For example if you want your pointer’s tooltip to point towards media menu then use id #menu-media instead of #menu-appearance or in case of settings menu use id #menu-settings
add_action( 'admin_enqueue_scripts', 'my_admin_enqueue_scripts' ); function my_admin_enqueue_scripts() { wp_enqueue_style( 'wp-pointer' ); wp_enqueue_script( 'wp-pointer' ); add_action( 'admin_print_footer_scripts', 'my_admin_print_footer_scripts' ); } function my_admin_print_footer_scripts() { $pointer_content = 'drumBEAT | Notice'; $pointer_content .= 'Added new functions to Edit Post section and few more options for users (authors and subscribers only).'; ?>
11. How to add custom pointers in WordPress admin area
The admin pages listing the site’s posts and pages come with various text columns like title, tags, categories, author and so on. In order to see what the featured images are, you have to visit each post or page individually. Using this hack you can add a column with a reasonably sized thumbnail copy of the featured image. Please note that this only works for themes that support featured images.
Just add following code to your theme’s functions.php file.
// Add the posts and pages columns filter. They can both use the same function. add_filter('manage_posts_columns', 'tcb_add_post_thumbnail_column', 5); add_filter('manage_pages_columns', 'tcb_add_post_thumbnail_column', 5); // Add the column function tcb_add_post_thumbnail_column($cols){ $cols['tcb_post_thumb'] = __('Featured'); return $cols; } // Hook into the posts an pages column managing. Sharing function callback again. add_action('manage_posts_custom_column', 'tcb_display_post_thumbnail_column', 5, 2); add_action('manage_pages_custom_column', 'tcb_display_post_thumbnail_column', 5, 2); // Grab featured-thumbnail size post thumbnail and display it. function tcb_display_post_thumbnail_column($col, $id){ switch($col){ case 'tcb_post_thumb': if( function_exists('the_post_thumbnail') ) echo the_post_thumbnail( 'admin-list-thumb' ); else echo 'Not supported in theme'; break; } }
12. Hide admin color scheme options from user profile
Adding this code to your theme’s functions.php will hide the admin color scheme from the user profile page in admin section.
function admin_color_scheme() { global $_wp_admin_css_colors; $_wp_admin_css_colors = 0; } add_action('admin_head', 'admin_color_scheme');