So you chose WordPress to power your client’s website but you find that you want to make just a few tweaks to better customize the website’s back-end admin area. The only problem is, you simply don’t know where to start.
So let’s get Started
Luckily the process is not incredibly difficult, it just requires some well written custom functions. Although your theme’s function.php file can appear to be a scary place, it truly it doesn’t have to be. To make things a little easier I’ve rounded up some of the best functions & hooks for WordPress and implementing them is as simple as copying and pasting the code into the correct location. But before you dive right in here are some important guidelines to take note of.
- Don’t modify your sites code via the built in WordPress code editor. If something goes wrong with the process you may end up seeing a blank screen that matches the equally blank look on your face. Rather take the time to set up FTP access and modify your code the right way. That way if the code you apply doesn’t work the way you expected you can simply press Command + Z and revert back to the files original state.
- Use a child theme. If you are running a theme you downloaded from WordPress.org or purchased from a trusted source it is good practice to create a child theme before you install it. Why you ask? Well… theme authors will often update a theme over time. If all your custom modifications are made in the main theme files they will be lost with every update. A child theme simply hooks into your parent theme allowing you to make modifications to the code without every touching the parent theme’s files.
Customizing the Admin Sidebar Menu
My guess is that a lot of thought and purpose went into the location of items in the default WordPress admin menu. However, there are instances when you simply may want to change those menus to better suit your needs. The functions below help you wrangle the default WordPress admin menu into perfect order.
Note: As you use the menu functions below you might find it necessary to reference this WordPress admin menu cheat sheet. It provides you the locations and codes for each menu item
Hiding Menus & Submenus
Often you need to give your client administrative privileges but don’t necessarily want them touching settings that could wreak havoc and potentially break the site. One way of handling this is by hiding certain menus or submenus. To do this just copy and paste the code below into your functions.php file and selectively add or delete the menus and submenus you want to hide.
[wc_toggle title=”Menu Cheat Sheet” padding=”” border_width=”” class=”” layout=”box”]
Dashboard: index.php
Posts: edit.php
Media: upload.php
Pages: edit.php?post_type=page
Comments: edit-comments.php
Custom Post Types: edit.php?post_type=your_post_type
Appearance: themes.php
Plugins: plugins.php
Users: users.php
Tools: tools.php
Settings: options-general.php
Note: If you get stuck use the Menu Cheat Sheet provided above.
// REMOVE WORDPRESS ADMIN MENUS
function remove_admin_menus (){
// Check that the built-in WordPress function remove_menu_page() exists in the current installation
if ( function_exists('remove_menu_page') ) {
/* Remove unwanted menu items by passing their slug to the remove_menu_item() function.
You can comment out the items you want to keep. */
remove_menu_page('edit.php'); // Posts Menu
remove_menu_page('users.php'); // Users Menu
remove_menu_page('tools.php'); // Tools Menu
remove_menu_page('options-general.php'); // Settings Menu
}}
// Add our function to the admin_menu action
add_action('admin_menu', 'remove_admin_menus');
Reordering Menus
Say you wanted to reorder some of the default WordPress admin menus. Copy and paste the code below into your functions.php file and order the menus listed in the array however you please.
Note: This code allows you to reorder any type of menu. The “Books” menu in the code below is an example of a standard custom post type. If you get stuck use the menu cheat sheet provided above.
// REORDER WORDPRESS ADMIN MENU
function custom_menu_order($menu_ord) {
if (!$menu_ord) return true;
return array(
'index.php', // Dashboard Menu
'edit.php', // Posts Menu
'edit.php?post_type=page', // Pages Menu
'edit.php?post_type=books', // Books Menu
'edit-comments.php', // Comments Menu
'upload.php', // Media Menu
); }
add_filter('custom_menu_order', 'custom_menu_order');
add_filter('menu_order', 'custom_menu_order');
Rebranding the Admin Area
For a truly white glove approach to the WordPress backend admin area you may want to remove or relabel things so your clients feel like they are getting a custom CMS tailored just for them. Here are a couple usefull functions for doing just that.
Removing the WordPress Icon
Here is a useful function that will remove the WordPress icon from the upper left corner of the admin panel. Once this code is placed in your themes functions.php file, the name of the website or blog that you defined in Settings > General will move slightly to the left taking the place of the default WordPress icon.
// REMOVE WORDPRESS ICON FROM ADMIN
function annointed_admin_bar_remove() {
global $wp_admin_bar;
/* Remove their stuff */
$wp_admin_bar->remove_menu('wp-logo'); }
add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);
Changing the Default Footer Text
This little bit of code will change the default text in the WordPress admin footer from “Powered by WordPress” to whatever you want it to be. To modify it just change what appears between the single quote marks after the echo in the code below.
// CUSTOMIZE WORDPRESS ADMIN FOOTER TEXT function modify_footer_admin () { echo 'Built for Inspired Magazine.'; // Enter your custom text/html after echo in the line above } add_filter('admin_footer_text', 'modify_footer_admin');
2
Comment