WordPress Admin Page Hacks
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 tofunctions.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. 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 );
6. 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');
|
7. 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
}
|
8. 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');
|
9. 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; } }
|
10. 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');
|
Comments
Post a Comment