11 Code Snippets to Customize Your WordPress Admin Dashboard

Posted by Joe Burrill | On | June 22, 2012 | Filed under Development

WordPress has very strong admin control panel to manage your WordPress website. There are so many WP plugins to customize your admin dashboard, some for to change the look n feel of the dashboard and some for the functionality. But major drawback of these plugins are their bulky nature, these make your WordPress site heavier in load time. So it would be better option not to use so many WordPress plugins. Then what should be the better alternative to these plugins? If you are a developer then you must be aware of ‘function.php’ file, it contains definition of all working WordPress functionality.


wordpress code snippets and hacks


Today, we are going to provide you 11 very useful code snippets to modify ‘function.php’ file to customize admin dashboard of your WordPress site. You just need to add these codes to the ‘function.php’ file; no more knowledge of core development is needed.


Remove items from your WordPress Dashboard’s Menu

// removing appearance, users and plugins options from menu Items in WordPress Dashboard
function wp_admin_dashboard_remove_menus() {
    global $menu;
    $restricted = array(__('Appearance'), __('Users'), __('Plugins'));
    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', 'wp_admin_dashboard_remove_menus');


List all Dashboard Widgets Within the Dashboard Itself

function list_active_dashboard_widgets() {
    global $wp_meta_boxes;
    foreach (array_keys($wp_meta_boxes['dashboard']['normal']['core']) as $name) {
	echo '<div>' . $name . '</div>';
add_action('wp_dashboard_setup', 'list_active_dashboard_widgets');


Editing the Footer Text in your Dashboard

function remove_footer_admin () {
    echo "Your own text";
add_filter('admin_footer_text', 'remove_footer_admin');


Changing the Colour of WordPress Dashboard’s Header

// Editing the WordPress Dashboard Header
function wp_admin_dashboard_header_colour() {
echo '<style type="text/css">#wphead{background:#000000;
background-image: -webkit-gradient(linear, 0% 100%, 0% 0%, from(#7684hg), to(#730fvk));
#wphead h1#site-heading a{color: #ggg;}
#wphead h1#site-heading a:hover{color: #fff;}
#wphead #wphead-info #user_info{color: #ggg;}
#wphead #wphead-info #user_info a{color: #ggg;}
#wphead #wphead-info #user_info a:hover{color: #fff;}
add_action('admin_head', 'wp_admin_dashboard_header_colour');


Adding a Custom Widget in Your WordPress Dashboard

add_action('wp_dashboard_setup', 'custom_dashboard_widgets');
function custom_dashboard_widgets() {
    global $wp_meta_boxes;
    wp_add_dashboard_widget('custom_ad_widget', 'MyAds', 'custom_dashboard_ad');

function custom_dashboard_ad() {
    echo '<p> Here is my widget.</p><br /> And one more line';


Error Logging in WordPress Dashboard

function slt_PHPErrorsWidget() {
	$logfile = '<root>/logs/php-errors.log'; // Enter the server path to your logs file here
	$displayErrorsLimit = 100; // The maximum number of errors to display in the widget
	$errorLengthLimit = 300; // The maximum number of characters to display for each error
	$fileCleared = false;
	$userCanClearLog = current_user_can( 'manage_options' );
	// Clear file?
	if ( $userCanClearLog && isset( $_GET["slt-php-errors"] ) && $_GET["slt-php-errors"]=="clear" ) {
		$handle = fopen( $logfile, "w" );
		fclose( $handle );
		$fileCleared = true;
	// Read file
	if ( file_exists( $logfile ) ) {
		$errors = file( $logfile );
		$errors = array_reverse( $errors );
		if ( $fileCleared ) echo '<p><em>File cleared.</em></p>';
		if ( $errors ) {
			echo '<p>'.count( $errors ).' error';
			if ( $errors != 1 ) echo 's';
			echo '.';
			if ( $userCanClearLog ) echo ' [ <b><a href="'.get_bloginfo("url").'/wp-admin/?slt-php-errors=clear" onclick="return confirm(\'Are you sure?\');">CLEAR LOG FILE</a></b> ]';
			echo '</p>';
			echo '<div id="slt-php-errors" style="height:250px;overflow:scroll;padding:2px;background-color:#faf9f7;border:1px solid #ccc;">';
			echo '<ol style="padding:0;margin:0;">';
			$i = 0;
			foreach ( $errors as $error ) {
				echo '<li style="padding:2px 4px 6px;border-bottom:1px solid #ececec;">';
				$errorOutput = preg_replace( '/\[([^\]]+)\]/', '<b>[$1]</b>', $error, 1 );
				if ( strlen( $errorOutput ) > $errorLengthLimit ) {
					echo substr( $errorOutput, 0, $errorLengthLimit ).' [...]';
				} else {
					echo $errorOutput;
				echo '</li>';
				if ( $i > $displayErrorsLimit ) {
					echo '<li style="padding:2px;border-bottom:2px solid #ccc;"><em>More than '.$displayErrorsLimit.' errors in log...</em></li>';
			echo '</ol></div>';
		} else {
			echo '<p>No errors currently logged.</p>';
	} else {
		echo '<p><em>There was a problem reading the error log file.</em></p>';

// Add widgets
function slt_dashboardWidgets() {
	wp_add_dashboard_widget( 'slt-php-errors', 'PHP errors', 'slt_PHPErrorsWidget' );
add_action( 'wp_dashboard_setup', 'slt_dashboardWidgets' );


Removing the Logo From the Dashboard

add_action('admin_head', 'my_custom_logo');
function my_custom_logo() {
   echo '<style type="text/css">
         #header-logo { background-image: url('.get_bloginfo('template_directory').'/images/logo.jpg) !important; }</style>';


Add a Custom News Feed to the WordPress Dashboard

// A news feed widget for your WordPress dashboard
function wp_admin_dashboard_add_news_feed_widget() {
    global $wp_meta_boxes;
    // The new widget
    wp_add_dashboard_widget( 'dashboard_new_feed', 'News of Your Choice', 'dashboard_my_feed_output' );
add_action('wp_dashboard_setup', 'wp_admin_dashboard_add_news_feed_widget');
function dashboard_my_feed_output() {
    echo '<div>';
        'url' => 'http://www.mywebsite.com/feed/',
        'title' => 'Latest news of my choice',
        'items' => 2,
        'show_summary' => 1,
        'show_author' => 0,
        'show_date' => 1
echo "</div>";


Removing the WordPress Logo from the Login Page

function my_custom_login_logo() {
    echo '<style type="text/css">
        h1 a { background-image:url('.get_bloginfo('template_directory').'/images/logo.jpg) !important; }
add_action('login_head', 'my_custom_login_logo');


Disable Non-Default Dashboard Widgets

function disable_default_dashboard_widgets() {
    remove_meta_box('widget-name', 'dashboard', 'normal');
add_action('admin_menu', 'disable_default_dashboard_widgets');


Remove the Upgrade WordPress Banner for Non-Admin Users

// Removing the "Please Update Now" notice for non-admin users
if ( !current_user_can( 'edit_users' ) ) {
    add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
    add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
    add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) ); 


***Bonus WordPress Plugins***


White Label CMS

This plugin gives the necessary freedom to WordPress administrators who can surprise their clients with a totally new WordPress dashboard.



Adminimize takes WordPress administration to next level by letting the administrator control literally every feature of WordPress from the dashboard itself.

♂ Author Info ♀

Written by Joe Burrill

Joe Burrill has written 640 posts on Blogger's Path

Spread the ❤

Related Posts☟


  1. By Tunji - June 24, 2012

    Please i would like to know if it is possible to customize a free wordpress site. Thanks

  2. By Amit - June 24, 2012

    Yes! You can customize your WordPress site whether it is running with free theme or premium theme, but you are advised to make proper backup before attempting any customization.

  3. By Jake - February 6, 2013

    Wow, very resourceful article and I had never even thought about modifying the WP dashboard.. Thanks for the code and tips.

Leave a comment