How to Customize the WordPress Admin Area

Recognized as one of the premier Content Management Systems (CMS), WordPress offers an extensive array of functiona

How to Customize the WordPress Admin Area Recognized as one of the premier Content Management Systems (CMS), WordPress offers an extensive array of functionalities that streamline website management. As a robust publishing platform, it includes a comprehensive comment system, a graphical user interface (GUI) for crafting, modifying, and overseeing posts and pages, as well as integrated tools such as the “Export” function for content backup, user roles and permissions, and more.However, the question arises: How many of these features do we actually utilize? While WordPress is inherently simple and user-friendly, we may opt to personalize the WordPress Admin interface to enhance its simplicity and manageability for clients, co-authors, and ourselves.Recently, WordPress has achieved extraordinary popularity.With over 25 million publishers relying on WordPress, it has become a go-to publishing platform. Its application extends beyond mere blogging to include portfolios, business websites, image galleries, and even e-commerce sites. However, this presents a challenge.Given its robust nature, a platform like WordPress is equipped with a myriad of features that a regular user may never require. Consider the “Comments” section, for instance: Not all users will necessitate all the moderation privileges it offers. Some sites may not even require commenting capabilities for their content.For example, a static informational site without a blog section may not want visitors to comment on pages like the “About Us” or “Contact Us” pages. The following image illustrates the default WordPress Dashboard, the first page visible upon logging into the Admin area. It is highly beneficial for tech-savvy individuals and power users.However, imagine a person, such as a paying client, who only needs to publish posts and possibly edit them. They have no interest in the additional features visible on the screen. They simply want to create content. Nothing more.Thankfully, WordPress provides a solution.A practical one. It is completely modular and reversible, allowing for a quick return to the original state if desired. This solution is known as “Hooks,” also referred to as “Filters” and “Actions.” These mechanisms enable us to integrate with the WordPress core without modifying its files, ensuring safe changes without compromising the integrity of the installation. We will utilize various actions and filters available in WordPress to eliminate unnecessary features. Additionally, we will implement basic customization changes to brand the WordPress Admin area for our clients.The code snippets provided are primarily from my website, WP Snippets, a searchable repository of WordPress snippets (please explore it when you have the opportunity).Let’s begin. The first step is to open the “functions.php” file in your theme’s directory.If you do not have a “functions.php” file, simply create one using your preferred text editor. The “functions.php” file is where we will place all our code. WordPress automatically checks this file, enabling customization before it is displayed on the screen.Seems a bit abstract? Here’s how it works. Try the following code.Rest assured, it will only impact the Admin area—your site visitors will not see it. However, I recommend experimenting offline by installing WordPress on your computer (it’s easier than you might think).<php function testing() { echo ‘Hello World!’; } add_action( ‘admin_head’, ‘testing’ ); ?>23 03 hello worldExplanationThe code will display “Hello World!” within the <head> tags in the Admin panel, which is not valid HTML code and, as a result, is printed at the top of the web page.The “testing” function is our code that we want to execute. To integrate with the WordPress core, we use the “add_action” function. In this case, we pass two parameters.The first parameter is the name of the action you want to integrate with (admin_head). The second parameter is the name of the function you want to run (testing). After testing this code snippet, be sure to remove it from your “functions.php” file (we are done with it).The first thing users will see when logging into the Admin area is the Dashboard. There, you’ll find widgets like “WordPress Blog,” “Other WordPress News,” and “Incoming Links.” These may not be of interest to the average user. We will utilize the “admin_head” action to remove them.In the function we want to execute, we will use the “remove_meta_box” function to remove the Dashboard widgets we do not want to display.Then, we simply call “add_action” using “wp_dashboard_setup” as the first parameter and our function, named “remove_dashboard_widgets,” as the second parameter.function remove_dashboard_widgets(){ global $wp_meta_boxes; unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_plugins’]); unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_recent_comments’]); unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_primary’]); unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_incoming_links’]); unset($wp_meta_boxes[‘dashboard’][‘normal’][‘core’][‘dashboard_right_now’]); unset($wp_meta_boxes[‘dashboard’][‘side’][‘core’][‘dashboard_secondary’]); } add_action(‘wp_dashboard_setup’, ‘remove_dashboard_widgets’);For more information on removing dashboard widgets, refer to the WordPress documentation.WordPress comes with 12 standard widgets.Some of these default widgets include Calendar, Search, and Recent Comments. You may want to disable widgets that are not needed for your WordPress installation to simplify and declutter your platform. For instance, you may not require a calendar, or perhaps you’ve employed a third-party search service like Google Custom Search for your client’s WordPress installation.For this, we will use the “widgets_init” action. We will name our function simply as “remove_some_wp_widgets.” In our function, we will use WordPress’s “unregister_widget” function with the names of the widgets we do not want to use as the parameter.Then, like before, we just call “add_action.” What you’ll see in this code snippet is a third parameter (1). The third parameter is the priority of the action.10 is the default priority, meaning that if you do not pass a value for this optional parameter, it will assume the value is 10. The lower the number, the higher the priority. So at 1, this is one of the top priority functions that will be called first, regardless of its position in the action hook.function remove_some_wp_widgets(){ unregister_widget(‘WP_Widget_Calendar’); unregister_widget(‘WP_Widget_Search’); unregister_widget(‘WP_Widget_Recent_Comments’); } add_action(‘widgets_init’, ‘remove_some_wp_widgets’, 1);For more information about the Widgets API, visit the WordPress documentation to discover other exciting features you can implement.You may want to remove menu items in the Admin panel to simplify the interface. Here’s how you can disable top-level menu items such as “Posts,” “Media,” “Appearance,” and “Tools”:function remove_menu_items() { global $menu; $restricted = array(__(‘Links’), __(‘Comments’), __(‘Media’), __(‘Plugins’), __(‘Tools’), __(‘Users’)); end ($menu); while (prev($menu)){ $value = explode(‘ ‘, $menu[key($menu)][0]); if(in_array($value[0] != NULL?$value[0]:”” , $restricted)){ unset($menu[key($menu)]); } } } add_action(‘admin_menu’, ‘remove_menu_items’);This is how you would remove submenu items under the top-level navigation (for example, the “Themes” link under “Appearance”): function remove_submenus() { global $submenu; unset($submenu[‘index.php’][10]); // Removes ‘Updates’ unset($submenu[‘themes.php’][5]); // Removes ‘Themes’ unset($submenu[‘options-general.php’][15]); // Removes ‘Writing’ unset($submenu[‘options-general.php’][25]); // Removes ‘Discussion’ unset($submenu[‘edit.php’][16]); // Removes ‘Tags’ } add_action(‘admin_menu’, ‘remove_submenus’);To find what the submenu names are, simply go to wp-admin/menu.php and search for the item you want to disable.The “Editor” link (a submenu item under “Appearance”) is a bit tricky to disable.It does not respond to the “remove_submenu_page” function used above. Therefore, if we wanted to remove it from the menu, we would have to remove the action that displays it. We will use the “remove_action” function to remove the action from our theme.function remove_editor_menu() { remove_action(‘admin_menu’, ‘_add_themes_utility_last’, 101); } add_action(‘_admin_menu’, ‘remove_editor_menu’, 1);The “Add New” and “Edit” pages—the GUI for creating and editing posts and pages—are likely the most frequently used features in the Admin area. We can improve these pages by removing unnecessary elements.For example, do you use any Custom fields or the Excerpts field? If not, simply remove them from this view. The following code snippet uses the “remove_meta_box” function.The first parameter is the meta box’s HTML ID attribute you want to remove. To find out the ID, simply inspect the source code or use a tool like the Web Developer Toolbar to determine the ID attribute value of the section’s containing <div>. For example, the Custom Fields’ ID is “postcustom,” so the parameter we use is “postcustom”.The second parameter refers to the page you want to remove the meta box from (it can be either “post”, “page”, or “media”). We will remove the custom field, Trackbacks checkbox (because most of the time, we either enable or disable it in all of our posts), the comments status option, tags (if you don’t tag your posts with keywords, why have this input field?), and so on.function customize_meta_boxes() { /* Removes meta boxes from Posts */ remove_meta_box(‘postcustom’,’post’,’normal’); remove_meta_box(‘trackbacksdiv’,’post’,’normal’); remove_meta_box(‘commentstatusdiv’,’post’,’normal’); remove_meta_box(‘commentsdiv’,’post’,’normal’); remove_meta_box(‘tagsdiv-post_tag’,’post’,’normal’); remove_meta_box(‘postexcerpt’,’post’,’normal’); /* Removes meta boxes from pages */ remove_meta_box(‘postcustom’,’page’,’normal’); remove_meta_box(‘trackbacksdiv’,’page’,’normal’); remove_meta_box(‘commentstatusdiv’,’page’,’normal’); remove_meta_box(‘commentsdiv’,’page’,’normal’); } add_action(‘admin_init’,’customize_meta_boxes’);WordPress’s Admin area often includes tables that provide a quick overview of a listing of your content.If you want to remove columns from these views, you can. This time, we will use the “add_filter” WordPress function to add a filter instead of an action. A filter is simply a function that monitors data being retrieved from the database.When it detects something we want to remove (or modify), it executes the filter first before rendering the data on the web page. In the example below, we will remove the comments count from the “Edit Pages” and “Edit Posts” pages.function custom_post_columns($defaults) { unset($defaults[‘comments’]); return $defaults; } add_filter(‘manage_posts_columns’, ‘custom_post_columns’); function custom_pages_columns($defaults) { unset($defaults[‘comments’]); return $defaults; } add_filter(‘manage_pages_columns’, ‘custom_pages_columns’);At the top bar of the Admin area is a dropdown called “favorites” that lists commonly used Admin tasks such as “New Post,” “Comments” (which takes you to the comment moderation page), and so on, for easy access.If we wanted to remove items in this menu, we can do so easily. (Of course, we can also add items here as well.) We can achieve this by adding another filter and unsetting the link, which is contained in a PHP array called “$actions”.function custom_favorite_actions($actions) { unset($actions[‘edit-comments.php’]); return $actions; } add_filter(‘favorite_actions’, ‘custom_favorite_actions’);Thus far, we have disabled unnecessary features.Now, we will modify a few things.Customize the FooterThe footer text in WordPress Admin includes links to the Documentation and to WordPress. Let’s change that.This snippet simply prints out some footer text.function modify_footer_admin () { echo ‘Created by <a href=”http://example.com”>Filip</a>.’; echo ‘Powered by<a href=”http://WordPress.org”>WordPress</a>.’; } add_filter(‘admin_footer_text’, ‘modify_footer_admin’);23 11 footer contentChange the Logo

How to Customize the WordPress Admin Area

How to Customize the WordPress Admin Area

Chat With Us

If you need to do Google SEO screen blocking business, please contact me immediately

Share:

More Posts