Vertical Centering an Image

Recently I had to vertically center an image, I tried all the css tricks. Making wrapper div as table and then inner div as table-cell with css property vertical-align:center.

On the other side it’s very easy to do with JQuery.

<div class="image_wrapper">

<img src="" alt="" class="my_image"/>





    //get the height of the parent  
    var parent_height = $('.my_image').parent().height();  

    //get the height of the image  
    var image_height = $('.my_image').height();  

    //calculate the top margin needed for the image to be at vertically center  
    var top_margin = (parent_height - image_height)/2;  

    //Change the margin-top css attribute of the image  
    $('.my_image').css( 'margin-top' , top_margin);  

Improve WordPress Page Loading Time & Overall Site Optimization

Your WordPress website needs to load fast. Faster websites keep visitors engaged. The difference between waiting 2 seconds and 5 seconds for a website to load is substantial. Google’s rankings are based partly on your  site speed and users are known to quickly leave a site if it loads in 5 seconds or more. WordPress speed optimization can dramatically increase your conversion rates while boosting your rankings in search, as Google uses website speed .

The most common (major) issues are:

  • Images need to be optimized
  • Too many redirects
  • Too many WordPress plugins
  • Not utilizing broswer cache
  • Server and coding issues

How to make website load fast and optimise the speed of your WordPress site?

There are few things you can do to improve site speed and user experience.

1: Make sure you are using a Cache plugin. Here is list of some good ones.W3 Total Cache

WP Super Cache

One of the best and most downlaoded cache plugin. Downloads: 4,808,605.

This plugin generates static html files from your dynamic WordPress blog. After a html file is generated your webserver will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP scripts.

Quick Cache

Downloads: 449,066

W3 Total Cache

downloads 2,446,750 times.

W3 Total Cache improves the user experience of your site by increasing server performance, reducing the download times and providing transparent content delivery network (CDN) integration.

2: Database Optimization

Optimize and clean your database regularly. You can do this from your host panel or you can use wordpress plugins.  There are two good plugins

Optimize Database after Deleting Revisions

Optimize DB

3: Post, Page, Comments Clean-Up:

Remove unnecessary post and page revisions and spam comments (site’s often have hundreds or thousands of these stored in the database)

4: Image Optimization:

Optimize images (reduce size, losslesly compress, properly resize images so they are scaled correctly)

5: Plugin Cleanup:

Check all your plugins for resource usage, remove unecessary plugins and/or install better replacements when possible

6: Fix 404 Errors:

Remove broken calls to the server causing 404 errors and decreasing page load time

 7: Minimize HTML, CSS & Javascript

Improve WordPress Security: 25 Essential Plugins + Tips

If you are running a WordPress-powered website, its security should be your primary concern. In

most cases, WordPress blogs are compromised because their core files and/or plugin are outdated;
outdated files are traceable and it’s an open invitation to hackers.

Plugins For Better Security

WP DB Backup
WP DB Backup is an easy to use plugin which lets you backup your core WordPress database tables just by a few clicks. Besides it is so easy, it has also been one of the most used plugin to secure your WP-powered website.

wp db backup Hardening WordPress Security: 25 Essential Plugins + Tips

WP Security Scan
With this plugin, scanning your WordPress-powered site will be a simple task. It finds the vulnerabilities in your site and offer useful tips on removing them.

wp security scan Hardening WordPress Security: 25 Essential Plugins + Tips

Ask Apache Password Protect
This plugin doesn’t control WordPress or mess with your database, instead it utilizes fast, tried-and-true built-in security features to add multiple layers of security to your blog.

askapache password protect Hardening WordPress Security: 25 Essential Plugins + Tips

Stealth Login
The Stealth Login plugin will help you to create custom URL addresses for login, registering and logout of WordPress.

stealth login Hardening WordPress Security: 25 Essential Plugins + Tips

Login Lockdown
Login Lockdown will help you to lock attempts for a period of time on logging in to your admin panel after a number of attempts.

login lockdown Hardening WordPress Security: 25 Essential Plugins + Tips

WP-DB Manager
This is another great plugin which allows you to manage your WP database. It could be used as an alternative to the WordPress Backup Manager.

wp db manager Hardening WordPress Security: 25 Essential Plugins + Tips

Admin SSL Secure Plugin
Another plugin for keeping your admin panel secure. It acts on the SSL encryption and is really useful against hackers or people trying to get unallowed access to your panel. It is the rival for the Chap Secure Login Plugin.

admin ssl Hardening WordPress Security: 25 Essential Plugins + Tips

User Locker
If you want to avoid brute-force hacking your site, then the User Locker plugin is right for you. It works on the same system as Login Lockdown, however, it’s a 5-stars rated WP plugin which has a great fame among its users.

user locker Hardening WordPress Security: 25 Essential Plugins + Tips

Limit Login Attempts
Limit Login Attempts blocks the internet address from making further attempts after a specified limit on retries is reached, making a brute-force attack difficult or impossible.

limit login attempts Hardening WordPress Security: 25 Essential Plugins + Tips

Login Encryption
Login Encrypt is a security plugin. It uses a complex combination of DES and RSA to encrypt and secure the login process to the admin panel.

login encryption Hardening WordPress Security: 25 Essential Plugins + Tips

One Time Password
This unique plugin will help you to set a one-time password for your login, in order to prevent logging of unwanted users from internet cafes or such.

one time password Hardening WordPress Security: 25 Essential Plugins + Tips

Antivirus is a quite popular security plugin which will help you to keep your blog secured against bots, viruses and malwares.

antivirus Hardening WordPress Security: 25 Essential Plugins + Tips

Bad Behavior
Bad Behavior is the plugin which helps you fight with those annoying spammers. The plugin will not only help you prevent spam messages on your blog, but also will try to limit access to your blog, so they won’t be able even to read it.

bad behavior Hardening WordPress Security: 25 Essential Plugins + Tips

Exploit Scanner
Search the files and database of your WordPress install for signs that may indicate that the files or the database has fallen victim to malicious hackers. Even if it’s another scan plugin, it’s worth a try.

exploit scanner Hardening WordPress Security: 25 Essential Plugins + Tips

User Spam Remover
The plugin’s name tells its functions, a popular plugin which will help you prevent and remove the unwanted spam messages.

user spam remover Hardening WordPress Security: 25 Essential Plugins + Tips

Block Bad Queries
This plugin attempts to block away all malicious queries attempted on your server and WordPress blog. It works in background, checking for excessively long request strings (i.e., greater than 255 chars), as well as the presence of either “eval(“ or “base64” in the request URI.

8 Essential Tips

Changing default “wp_” Prefixes

Your website might be at stake if you are using the predictable wp_ prefixes in your database. The following tutorial teaches you how to get them changed via phpMyAdmin in 5 simple steps.

You can also get this done with WP Security Scan plugin.

Hide login error messages

Error login messages may expose and give hackers an idea if they’ve gotten username correct/incorrect, vice versa. It is wise to hide it from unauthorized login.

To hide login error messages, simply put the following code in functions.php

add_filter('login_errors',create_function('$a', "return null;"));


Keep wp-admin Directory Protected

Keeping “wp-admin” folder protected adds an extra layer of protection. Whoever attempts to access files or directory after “wp-admin” will be prompt to login.

Protecting your “wp-admin” folder with login and password can be done in several ways:

  • WordPress plugin – Using the WordPress AskApache Password Protect plugin.
  • cPanel – If your hosting supports cPanel admin login, you can set protection easily on any folder via cPanel’s Password Protect Directories graphical user interface. Find out more from this tutorial.
  • .htaccess + htpasswd – Creating a password-protected folder can also be done easily by setting the folders you want to protect inside .htaccess and users allowed to access inside .htpasswd. The following tutorial shows you how to do it in 7 steps.

Maintaining backups

Keeping backup copies of your entire WordPress blog is as important as keeping the site safe from hackers. If the latter fail, at least you still have the clean backup files to revert.

Prevent directory browsing

Another big security loophole is having your directories (and all its files) exposed and accessible to public. Here’s a simple test to check if your WordPress directories are well protected:

  • Enter the following URL in browser, without the quotes. “”

If it shows blank or redirect you back to home page, you are safe. However, if you see screen similar to the image below, you are not.

protect directory file listing Hardening WordPress Security: 25 Essential Plugins + Tips

To prevent access to all directories, place this code inside your .htaccess file.

# Prevent folder browsing
Options All -Indexes

Keep WordPress core files & Plugins updated

One of the safest ways to keep your WordPress site safe is to make sure your files are always updated to the latest release. Here are couple of ways (practices) you can do:

  • Login to Dashboard often – A yellow notification will appear at the top of the Dashboard if update is available. Login often and keep yourself updated to the latest copy of WordPress core files.
  • Deactivate and remove unused plugins – Unused plugin will eventually get outdated and may pose a security risk. If you are not using it, delete it.
  • Subscribe to WordPress Releases RSS.

Pick a Strong Password

Is your password safe? A strong and safe password is more than just something memorable with numbers (e.g., john123). For starters, it should consist of more than 12 characters with the combination of numbers and alphabets in lower and uppercases.

Here are some applications that allow you to generate strong password:

Remove admin user

A typical installation of WordPress comes with a default user named “admin”. If that’s the username to your WordPress site, you are already making hacker’s life 50% easier. Using user “admin” should be avoided at all times.

A safer approach to logging into your admin securely is to create a new administrator and have “admin” removed. And here’s how you do it:

  1. Login to WordPress admin panel
  2. Go to Users -> Add New
  3. Add a new user with Administrator role, make sure you use a strong password.
  4. Log out of WordPress, re-login with your new admin user.
  5. Go to Users
  6. Remove “admin” user
  7. If “admin” have posts, remember to attribute all posts and links back to the new user.


20 Helpful WordPress SQL Queries Snippets

There are endless reasons for editing the WordPress database, but there are always those SQL queries that are needed more than the rest. And that is what we have for you today.

Always Backup WordPress First

Your WordPress database stores every single one of your carefully written posts, every comment from your loyal readers and every setting that you have used to personalize your site. So, no matter how confident you are with your ability to use these SQL queries, please, please, always remember to backup your WordPress database first.

Here are some resources to help yo backup WordPress:

· WordPress Backups – Here you will find detailed instructions to back up your WordPress Site and your WordPress Database as well as resources for automatic WordPress backups (plugins).

· How to Backup the WordPress Database – PhpMyAdmin – This less detailed tutorial will show you how to backup your WordPress database in phpMyAdmin.

· WP-DB-Backup Plugin – WP-DB-Backup allows you to automate the backup of your core WordPress database.

Add a custom field to all posts and pages

This useful snippet will add a custom field to both posts and pages within your WP database. All you have to do is replace the ‘UniversalCutomField‘ to whatever name you like and then change ‘MyValue‘ to the value of your choice.

INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
SELECT ID AS post_id, 'UniversalCustomField'
AS meta_key 'MyValue AS meta_value FROM wp_posts
WHERE ID NOT IN (SELECT post_id FROM wp_postmeta WHERE meta_key = 'UniversalCustomField');

For posts only, use this snippet…

INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
SELECT ID AS post_id, 'UniversalCustomField'
AS meta_key 'MyValue AS meta_value
(SELECT post_id FROM wp_postmeta WHERE meta_key = 'UniversalCustomField')
`` AND post_type = 'post';

…and for pages only, use this code…

INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
SELECT ID AS post_id, 'UniversalCustomField'
AS meta_key 'MyValue AS meta_value
(SELECT post_id FROM wp_postmeta WHERE meta_key = 'UniversalCustomField')
AND `post_type` = 'page';


Delete Post Meta

When you install or remove plugins they make use of the post meta to store data. After you have removed the plugin, the data will still remain inside the post_meta table, which of course, is no longer needed. Remember and change ‘YourMetaKey‘ to your own value before running this query.

DELETE FROM wp_postmeta WHERE meta_key = 'YourMetaKey';


Identify Unused Tags

In a WordPress database, if you run a query to delete old posts, as the one above, the old tags will remain and appear in your tag cloud/listing. This query allows you to identify the unused tags.

SELECT * From wp_terms wt
INNER JOIN wp_term_taxonomy wtt ON wt.term_id=wtt.term_id WHERE wtt.taxonomy='post_tag' AND wtt.count=0;


Batch Deleting Spam Comments

This little snippet was a life-saver a few weeks back when we had over 60,000 (really!) spam comments.
All you have to do is run this SQL command:

DELETE FROM wp_comments WHERE wp_comments.comment_approved = 'spam';


Batch Deleting All Unapproved Comments

This SQL query will remove all of yourthe unapproved comments and will not touch your approved comments.

DELETE FROM wp_comments WHERE comment_approved = 0


Disable Comments on Older Posts

For this query, specify the comment_status as either open, closed, or registered_only. Also, specify the date by editing the 2010-01-01 to suit your needs.

UPDATE wp_posts SET comment_status = 'closed' WHERE post_date < '2010-01-01' AND post_status = 'publish';


Disabling and Enabling Trackbacks & Pingbacks

For this query, specify the comment_status as either open, closed, or registered_only.

Globally enable pingbacks/trackbacks for all users:

UPDATE wp_posts SET ping_status = 'open';

Globally disable pingbacks/trackbacks for all users:

UPDATE wp_posts SET ping_status = 'closed';

Enable/Disable Pingbacks & Trackbacks Before a Certain Date

For this query, specify the ping_status as either open or closed. Also, specify the date by editing the 2010-01-01 to suit your needs.

UPDATE wp_posts SET ping_status = 'closed' WHERE post_date < '2010-01-01' AND post_status = 'publish';


Delete Comments With A Specific URL

If you have spam comments that all contain the same URL then this query allows you to remove them in one go. The following query will delete all comments with a specific url. The ‘%’ means that any url containing the string within the ‘%’ signs will be deleted.

DELETE from wp_comments WHERE comment_author_url LIKE "%nastyspamurl%" ;


Identify & Delete Posts that are over ‘X’ Days Old

If you ever need to identify and delete posts that are over a certain amount of days old, then this snippet will help.

To identify any posts that are over ‘X’ amount of days run this query, remembering to replace the ‘X’ with the amount of days you are looking for:

SELECT * FROM `wp_posts`
WHERE `post_type` = 'post'
AND DATEDIFF(NOW(), `post_date`) > X

To delete any posts that are over ‘X’ amount of days run this query:

DELETE FROM `wp_posts`
WHERE `post_type` = 'post'
AND DATEDIFF(NOW(), `post_date`) > X


Removing Unwanted Shortcodes

WordPress shortcodes are great, but when you decide to stop using them, their code will stay within your post content. Here is a simple SQL query to run on your database to get rid of any unwanted shortcodes. Replace ‘tweet‘ with your own shortcode name.

UPDATE wp_post SET post_content = replace(post_content, '[tweet]', '' ) ;


Change Your WP Posts Into Pages and Vice-Versa

Changing posts to pages is very easy, all you have to do is run this short SQL query through PHPMyAdmin:

UPDATE wp_posts SET post_type = 'page' WHERE post_type = 'post'

… and if you want to change pages to posts use this snippet:

UPDATE wp_posts SET post_type = 'post' WHERE post_type = 'page'


Change Author Attribution On All Posts

The first thing you will need to do for this snippet is retrieve the IDs of the WordPress author. You can find this out by using the following SQL command:

SELECT ID, display_name FROM wp_users;

Once you have the old and new IDs, insert the command below, remembering to replace ‘NEW_AUTHOR_ID‘ with the new authors ID and ‘OLD_AUTHOR_ID‘ with the old.

UPDATE wp_posts SET post_author=NEW_AUTHOR_ID WHERE post_author=OLD_AUTHOR_ID;


Batch Deleting Post Revisions

Post revisions can be very useful, but they also considerably increase the size of your MySQL database. You could manually delete posts revisions, but a much quicker method would be to use this SQL query.

DELETE FROM wp_posts WHERE post_type = "revision";


Disable or Enable All WordPress Plugins

If you have ever been faced with the white screen of death and found yourself unable to login to the WordPress Admin after activating a new plugin, then this snippet will certainly help you. It will disable all plugins instantly, allowing you to log back in.

UPDATE wp_options SET option_value = 'a:0:{}' WHERE option_name = 'active_plugins';


Changing the Destination URL of a WordPress Site

Once you’ve moved your blog (template files, uploads & the database) from one server to another, the next thing you will then need to do is to tell WordPress your new address.

Remember and change ‘‘ to your old URL, and the ‘’ to your new URL.
The first command to use is:

UPDATE wp_options SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl';

Then you will have to change the url from the table wp_posts with this snippet:

UPDATE wp_posts SET guid = replace(guid, '',';

And finally, you’ll need to do a search through the content of your posts to be absolutely sure that your new URL link is not messing with the old URL:

UPDATE wp_posts SET post_content = replace(post_content, ' ', ' ');


Change the Default ‘Admin’ Username

Every WordPress installation will create an account with the default Admin username. Being able to change this default username, will give your WordPress admin panel additional security.

Change ‘YourNewUsername‘ to your new name:

UPDATE wp_users SET user_login = 'YourNewUsername' WHERE user_login = 'Admin';


Manually Reset your WordPress Password

If you’ve only a single user on your WordPress installation, and the login name is admin. You can reset your password with just this simple SQL query, which once executed will replace PASSWORD with your new password.

UPDATE `wordpress`.`wp_users` SET `user_pass` = MD5('PASSWORD') WHERE `wp_users`.`user_login` =`admin` LIMIT 1;


Search and Replace Post Content

To search and replace within the post content area of WordPress use the following code. Replace ‘OriginalText‘ with the original text you would like to change and replace ‘ReplacedText‘ with your new text.

UPDATE wp_posts SET `post_content`
= REPLACE (`post_content`,


Changing the URL of Images

If you need to change the paths of your images, you can use this SQL command below:

UPDATE wp_posts
SET post_content = REPLACE (post_content, 'src=”', 'src=”');


20 Snippets and Hacks to Make WordPress User-Friendly for your Clients

The snippets below will allow you to control almost all aspects of WordPress` Admin area and customize it to benefit your clients level of tech comfort.

Disabling Plugin Deactivation

This snippet is particularly useful if you have given a client plugin activation/deactivation privileges (allowing them to add new plugins themselves), but the site you have built requires some core plugins to function and should never be deactivated.
The code below will remove the ‘Deactivate’ links from whichever plugins you deem fundamental as well as removing the ‘Edit’ links from all plugins.

Paste this into your functions.php:

add_filter( 'plugin_action_links', 'slt_lock_plugins', 10, 4 );
function slt_lock_plugins( $actions, $plugin_file, $plugin_data, $context ) {
	// Remove edit link for all
	if ( array_key_exists( 'edit', $actions ) )
		unset( $actions['edit'] );
	// Remove deactivate link for crucial plugins
	if ( array_key_exists( 'deactivate', $actions ) && in_array( $plugin_file, array(
		unset( $actions['deactivate'] );
	return $actions;

Source →

Disabling Theme Changing

Just like the Plugin Disabling code above, you really don’t want your clients tinkering or experimenting with any theme changes. The code below will remove the ‘Appearance’ menu option from the Dashboard.

Paste this into your functions.php:

add_action( 'admin_init', 'slt_lock_theme' );
function slt_lock_theme() {
	global $submenu, $userdata;
	if ( $userdata->ID != 1 ) {
		unset( $submenu['themes.php'][5] );
		unset( $submenu['themes.php'][15] );

Source →

Disable Top-Level Menus from the Admin Panel

Depending on your client, you may need to take disabling/hiding WordPress menu options even further. With this snippet you can hide whichever Top-Level Menu (Posts, Media, Links, Tools…) you need to.

Paste this into your functions.php:

function remove_menus () {
global $menu;
	$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('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', 'remove_menus');

Source →

Disable Submenus from the Admin Panel

Maybe your client doesn’t need the drastic action taken by the above snippets, and only needs some key sub-menu items disabled/hidden. This code will help.

Paste this into your functions.php:

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'.
add_action('admin_menu', 'remove_submenus');

The menu-ID:s are found in wp-admin/menu.php.

Source →

Restrict Admin Menu Items Based on Username

Say you want to restrict client access to certain Top-Level menu items, but you still want to maintain the full menu for the main administrator, this snippet will help.

Replace ‘clients-username’ and paste this code into your functions.php:

function remove_menus()
    global $menu;
    global $current_user;

    if($current_user->user_login == 'clients-username')
        $restricted = array(__('Posts'),
        end ($menu);
        while (prev($menu)){
            $value = explode(' ',$menu[key($menu)][0]);
            if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
        }// end while

    }// end if
add_action('admin_menu', 'remove_menus');

Source →

Remove Meta-Boxes from Posts & Pages Editor Screens

Publishing posts and pages are more than likely key to your clients business and probably the main reason you chose WordPress for them in the first place. To help avoid any confusion from within the posts/pages editor screens it could be helpful to remove unused meta-boxes (custom fields, recent comments, post tags…).

Paste this into your functions.php and edit as required:

function remove_extra_meta_boxes() {
remove_meta_box( 'postcustom' , 'post' , 'normal' ); // custom fields for posts
remove_meta_box( 'postcustom' , 'page' , 'normal' ); // custom fields for pages
remove_meta_box( 'postexcerpt' , 'post' , 'normal' ); // post excerpts
remove_meta_box( 'postexcerpt' , 'page' , 'normal' ); // page excerpts
remove_meta_box( 'commentsdiv' , 'post' , 'normal' ); // recent comments for posts
remove_meta_box( 'commentsdiv' , 'page' , 'normal' ); // recent comments for pages
remove_meta_box( 'tagsdiv-post_tag' , 'post' , 'side' ); // post tags
remove_meta_box( 'tagsdiv-post_tag' , 'page' , 'side' ); // page tags
remove_meta_box( 'trackbacksdiv' , 'post' , 'normal' ); // post trackbacks
remove_meta_box( 'trackbacksdiv' , 'page' , 'normal' ); // page trackbacks
remove_meta_box( 'commentstatusdiv' , 'post' , 'normal' ); // allow comments for posts
remove_meta_box( 'commentstatusdiv' , 'page' , 'normal' ); // allow comments for pages
remove_meta_box('slugdiv','post','normal'); // post slug
remove_meta_box('slugdiv','page','normal'); // page slug
remove_meta_box('pageparentdiv','page','side'); // Page Parent
add_action( 'admin_menu' , 'remove_extra_meta_boxes' );

Source →

Remove Pages Columns

Adding this code allows you to remove whichever column from the ‘Pages’ page you feel are not necessary to your client.

Edit as required and paste this snippet into your functions.php:

function remove_pages_columns($defaults) {
  return $defaults;
add_filter('manage_pages_columns', 'remove_pages_columns');

Source →

Remove Posts Columns

Similar to the snippet above, this code will remove columns from the posts page.

Edit as required and paste this code into your functions.php:

function remove_post_columns($defaults) {
  return $defaults;
add_filter('manage_posts_columns', 'remove_post_columns');

Source →

Removing Default Widgets from the Dashboard

The majority of the default Dashboard widgets may not be necessary to your non-tech client and could potentially be a disastrous distraction. This snippet will remove whichever widget you define from the Dashboard.

Paste this into your functions.php:

// Create the function to use in the action hook
function example_remove_dashboard_widgets() {
	// Globalize the metaboxes array, this holds all the widgets for wp-admin

	global $wp_meta_boxes;

	// Remove the incomming links widget

	// Remove right now

// Hoook into the 'wp_dashboard_setup' action to register our function
add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );

To view each widget’s call have a look at the Dashboard Widgets API page on the Codex.

Source →

Create Personalized Dashboard Widgets

When building themes for clients it could be useful, and appreciated, to create a personalized ‘Welcome’ widget on the Dashboard. This snippet will create a simple ‘Hello World’ widget, and can be easily edited to your own specifications.

Paste this code into your functions.php:

// Create the function to output the contents of our Dashboard Widget
function example_dashboard_widget_function() {
	// Display whatever it is you want to show
	echo "Hello World, I'm a great Dashboard Widget";

// Create the function use in the action hook
function example_add_dashboard_widgets() {
	wp_add_dashboard_widget('example_dashboard_widget', 'Example Dashboard Widget', 'example_dashboard_widget_function');
// Hoook into the 'wp_dashboard_setup' action to register our other functions
add_action('wp_dashboard_setup', 'example_add_dashboard_widgets' );

Source →

Add, Remove & Reorder Dashboard Widgets By Role

You may have a client that needs the WordPress Dashboard customized depending on user roles, by restricting editors or authors to all of admins details. This code will get rid of the ‘Incoming Links’ widget for authors and editors and then clean up some of the other boxes for everyone.

Paste this into your functions.php:

function tidy_dashboard()
  global $wp_meta_boxes, $current_user;

  // remove incoming links info for authors or editors
  if(in_array('author', $current_user->roles) || in_array('editor', $current_user->roles))
    unset($wp_meta_boxes['dashboard']['normal ']['core']['dashboard_incoming_links']);

  // remove the plugins info and news feeds for everyone

//add our function to the dashboard setup hook
add_action('wp_dashboard_setup', 'tidy_dashboard');

Here’s a list of how to unset each of the current default dashboard widgets:

//Right Now - Comments, Posts, Pages at a glance
//Recent Comments
//Incoming Links
//Plugins - Popular, New and Recently updated WordPress Plugins

//Wordpress Development Blog Feed
//Other WordPress News Feed
//Quick Press Form
//Recent Drafts List

Source →

Remove Author Metabox/Options & Move to Publish MetaBox

This code will remove the Author MetaBox and Screen Options and then add those option into the publish metabox.

Paste this into your functions.php:

add_action( 'admin_menu', 'remove_author_metabox' );
add_action( 'post_submitbox_misc_actions', 'move_author_to_publish_metabox' );
function remove_author_metabox() {
    remove_meta_box( 'authordiv', 'post', 'normal' );
function move_author_to_publish_metabox() {
    global $post_ID;
    $post = get_post( $post_ID );
    echo '<div id="author" class="misc-pub-section" style="border-top-style:solid; border-top-width:1px; border-top-color:#EEEEEE; border-bottom-width:0px;">Author: ';
    post_author_meta_box( $post );
    echo '</div>';

Source →

Add or Remove Links to the New WP Admin Bar

The new Admin Bar gives you quick access to all of the main areas of your site, like creating a new post or page, moderating comments or modifying widgets. The snippets below will allow you to add or remove any links.

This snippet will add links to the admin bar. Paste into your functions.php:

function my_admin_bar_link() {
	global $wp_admin_bar;
	if ( !is_super_admin() || !is_admin_bar_showing() )
	$wp_admin_bar->add_menu( array(
	'id' => 'diww',
	'parent' => 'my-blogs',
	'title' => __( 'Title of the link you want to add'),
	'href' => admin_url( '' )
	) );
add_action('admin_bar_menu', 'my_admin_bar_link');

This snippet will remove links from the admin bar. Paste into your functions.php:

function remove_admin_bar_links() {
	global $wp_admin_bar;
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );

Source →

Show an Urgent Message in the WP Admin

This snippet will allow you to shows a custom message to any logged in user. Particularly useful if you need to inform a client/user that they have done something wrong.

Firstly, paste this into your functions.php:

 * Generic function to show a message to the user using WP's
 * standard CSS classes to make use of the already-defined
 * message colour scheme.
 * @param $message The message you want to tell the user.
 * @param $errormsg If true, the message is an error, so use
 * the red message style. If false, the message is a status
  * message, so use the yellow information message style.
function showMessage($message, $errormsg = false)
	if ($errormsg) {
		echo '<div id="message" class="error">';
	else {
		echo '<div id="message" class="updated fade">';

	echo "<p><strong>$message</strong></p></div>";

Next, add a hook to the admin notices function to show your custom message:

 * Just show our message (with possible checking if we only want
 * to show message to certain users.
function showAdminMessages()
    // Shows as an error message. You could add a link to the right page if you wanted.
    showMessage("You need to upgrade your database as soon as possible...", true);

    // Only show to admins
    if (user_can('manage_options') {
       showMessage("Hello admins!");

  * Call showAdminMessages() when showing other admin
  * messages. The message only gets shown in the admin
  * area, but not on the frontend of your WordPress site.
add_action('admin_notices', 'showAdminMessages');

Source →

Hide the WordPress Upgrade Message

You may have clients who do not want to deal with any maintenance updates. For those clients, using this snippet, you can hide the WordPress Upgrade Message.

Paste this into your functions.php:

function wphidenag() {
remove_action( 'admin_notices', 'update_nag', 3 );

Source →

Simpler Login URL

The default URL for logging into your WordPress powered site is: To make things easier, or at least more memorable, for a client you will need a cleaner URL like:

Paste this code in your .htaccess file before the default WordPress rewrite stuff:

RewriteRule ^login$ [NC,L]

Source →

Change the Dashboard Footer Text

When building a site for a client, it can be useful to be able to customize the dashboard footer text. This little snippet will do the job.

Edit “Your own text” and paste this into your functions.php:

function remove_footer_admin () {
    echo "Your own text";

add_filter('admin_footer_text', 'remove_footer_admin');

Source →

Changing the WP Login Logo

When building themes for clients, one of their expectations may be to have some sort of company branding within WPs admin. The first page a client will ever view is the login screen and its very easy to customize by simply replacing the default WordPress logo with your clients company logo.

The new logo should be 326×82 pixels and copy it to your themes ‘images’ folder.

Edit ‘companylogo.png’ and paste this code into your functions.php:

// login page logo
function custom_login_logo() {
	echo '<style type="text/css">h1 a { background: url('.get_bloginfo('template_directory').'/companylogo.png) 50% 50% no-repeat !important; }</style>';
add_action('login_head', 'custom_login_logo');

Source →

Adding a Custom Dashboard Logo

The next step in customizing WPs backend is to replace the Dashboards logo. You will need to create a transparent (.gif or .png) image of 30x31px. Then, save that image in your theme’s image folder (/wp-content/themes/theme-name/images) and name it whatever you like.

Edit ‘custom-logo.gif’ and paste this snippet into your functions.php:

//hook the administrative header output
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/custom-logo.gif) !important; }

Source →

10 WordPress Plugins to Help Optimize Performance

WordPress has some really good plugins that can make a site load much faster, here are some  that will aid in improving and optimising your sites performance.

WP file Cache

This plugin implements object level persistent caching and can be used instead of the built in WordPress WP_Object_Cache. It will also aid in significantly reducing the load-time from your database. However, it should be noted that WP File Cache shifts the load from your database to your disk/file system and if Disk I/O is a bottleneck, file based caches will not help you.

Quick Cache (Alternative to WP Super Cache)

Quick Cache
This is a very useful plugin when it comes to optimizing your website’s speed. Quick Cache takes a real-time snapshot (building a cache) of every Page, Post, Category, Link, etc. These snapshots are then stored (cached) intuitively, so they can be referenced later, in order to save all of that processing time that has been slowing your site down.
It uses configuration options, that you select from the options panel.
Quick Cache uses advanced techniques that allow it to recognize when it should and should not serve a cached version of the file.

W3 Total Cache

This plugin helps to improve the sites’s performance via caching: browser, page, object, database, minify and content delivery network support. It improves the user experience of your site by improving your server performance, caching every aspect of your site, reducing the download times and providing transparent content delivery network (CDN) integration


WP Minify

This plugin integrates the Minify Engine (a PHP5 app that helps you to follow several of Yahoo!’s Rules for High Performance Web Sites) into your WordPress blog, to combine and compress JS and CSS files to improve page load time. Some of its features include – debug tools, plugin hooks, support for minifying external files via caching, ability to pass extra arguments to minify engines etc.


Parallelize allows automatically parallelizing WordPress attachement files (images or any files uploaded with the wordpress media features) across multiple hostnames, speeding page load. To assist caching, resources will always load from the same hostname.


This plugin reduces image file size and improves performance using the API within WordPress. Every image added to the page is automatically run through on the fly.

WP HTTP Compression

This plugin will allow your WordPress blog to output pages compressed in gzip format, if a browser supports compression. However, it should be noted that this plugin should not be used alongside WP Super Cache or WP Cache as those plugins are already implementing compression. Your blog will keep working but those plugins will stop caching new pages.
HTTP compression generally means a 60-80% REDUCTION in the size of your pages (broadband usage) as well as an INCREASE in download speeds of 3x to 4x.

Hyper Cache

This plugin is flexible and easy to configure cache system for WordPress. This is a new cache system for WordPress, specifically written for people who have their blogs on a low resource hosting provider. It can work even with hosting based on Microsoft IIS. Its features are easy to configure, easy to integrate with other plugins, global translator compatibility, redirects caching, auto clean system to reduce the disk usage and more.

WP Super Cache

This plugin generates static HTML files from your dynamic WordPress blog. After a HTML file is generated, your web server will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP scripts.
99% of your visitors will be served static html files. Those users who don’t see the static files will still benefit because they will see different cached files that aren’t quite as efficient but still better than uncached.

DB Cache Reloaded

This plugin caches every database query within a given lifetime. It is much faster than other HTML caching plugins and uses less disk space for caching. DB Cache Reloaded ensures that a site works much faster and uses less disk space for cached files. It also makes sure that visitors always get actual information in sidebars and server CPU loads are as low as possible.

CDN tools

This plugin is designed to help you drastically speed up your blog’s load time by loading data onto a content distribution network (CDN). It allows you to load Javascript and media files to an external server to drastically speed page loads. You can side load data to a commercial CDN or just load your larger JS libraries (Prototype, jQuery) for free from Google’s servers.