Custom header on plugin page at

A few days ago Automattic added a very nice feature for all plugin pages on Plugin developers are now able to control the header image on the plugin page.

Matt describes this function on WordPress development updates. He also states that this function is an experiment and will likely be changed in the future.

To see a list of several plugins that already have added a custom header check out WP Candy’s post on this update.

Custom header on plugin pages at

Custom header on plugin pages at

Posted in News, WordPress | Leave a comment

Make sure that you are ready for WordPress 3.2

WordPress 3.2 will soon be released and at the same time the requirements for WordPress will be higher than for previous versions.

The new requirements are:

  • PHP version 5.2.4 or greater
  • MySQL version 5.0 or greater

How do I know if I meet the requirements?

Either you check directly with your host or you can use a WordPress plugin. In WordPress plugin directory there are two plugins that you can use.

Posted in WordPress | Tagged , , | Leave a comment

The Ultimate WordPress Cheatsheet [Infographic]

Tech king has put together a nice infographic that you can use if you work with WordPress themes. It covers the anatomy of WordPress theme, a template checklist, include tags, template tags and other useful information.

Posted in Infographics, WordPress | Tagged | 3 Comments

Easy Excerpt is updated to version 0.3.0

My WordPress plugin Easy Excerpt which you can use to changed the appearance of your excerpts is now updated to version 0.3.0.

New in this version:

  • Added license information
  • Made plugin ready for translation
  • Added Swedish translation
Posted in Plugins, WordPress | Tagged , | 2 Comments

Add a custom default avatar to your WordPress site

WordPress have a built in support for gravatars which means that WordPress will automatically fetch the avatar associated with the commenting users email address. If the email address is not associated with an avatar WordPress will display a default avatar. You as a site owner can choose between a set of default avatars but you can also add your own custom avatar. Choose default avatar from the discussion page under the settings menu.

WordPress Default Avatars

WordPress Default Avatars

How to add a default custom avatar

To add a custom avatar, place the following code in your functions.php located in your theme folder.

add_filter( 'avatar_defaults', 'new_avatar' );
function new_avatar($avatar_defaults) {
	$new_avatar = get_stylesheet_directory_uri() . '/images/custom-default-avatar.png';
	$avatar_defaults[$new_avatar] = "Site name";
	return $avatar_defaults;

“Site name” is the text to the right of the avatar in the image above. Change it to something appropriate. Also, don’t forget to add the image to the images directory.

Posted in Tutorials, WordPress | Tagged , , , | Leave a comment

Only include Contact Form 7 javascript and CSS when needed

The Contact Form 7 is a great WordPress plugin for adding contact forms to your site. The plugin is very easy to use and make nice contact forms with.

The bad news is that the plugin includes javascript and CSS on every page which makes your site load slower than necessary. The good news is that there is an easy fix for it.

By adding the two following code snippets to your themes functions.php you can remove the javascript and CSS from all pages that don’t use it which makes your site load faster.

Remove Contact Form 7 javascript

add_action( 'wp_print_scripts', 'deregister_cf7_javascript', 100 );
function deregister_cf7_javascript() {
	if ( !is_page(100) ) {
		wp_deregister_script( 'contact-form-7' );

Remove Contact Form 7 CSS

add_action( 'wp_print_styles', 'deregister_cf7_styles', 100 );
function deregister_cf7_styles() {
	if ( !is_page(100) ) {
		wp_deregister_style( 'contact-form-7' );

In both code snippets, change the number 100 to the id of the page where you have added the contact form or use the page slug instead.

Posted in Plugins, Tutorials, WordPress | Tagged , , , , , , | 29 Comments

WordPress plugins – Types and statuses

WordPress plugins is what gives WordPress the extra power and enables you to extend the functionality of WordPress so that you can do more or less anything you like. At the time of writing this post almost 14 thousand plugins exists in WordPress plugin directory.

Most users of WordPress think that there is only one type of plugin. However, there is actually three types of plugins that you can use.

WordPress Plugin - Types and Statuses

WordPress Plugin - Types and Statuses

Normal plugins

This is the plugins that you normally download from the plugin directory at These plugins are located in the wp-content/plugins directory.

These plugins can have the following statuses.

  • Active – The plugin is active and plugin code will be executed
  • Inactive– The plugin is installed but inactive and no code is executed
  • Upgrade Available – A new version of the plugin is available

Must-use plugins

The must-use plugins are very similar to normal plugins. The main difference is that they are placed in the wp-content/mu-plugins directory and can not be located in a subfolder.

The mu-plugins directory is created by default if you install WordPress Multisite (WordPress MS) but you can use it in the normal installation of WordPress if you manually create the mu-plugins directory.

These plugins are activated by default and the only way to deactivate them is to remove them from the mu-plugins directory. Must-use plugins are listed under “Must-use” in the plugins page.

Drop-ins plugins

Drop-ins are plugins that can replace core functionality of WordPress. These kind of plugins are placed in the wp-content directory and must be named in a certain way for WordPress to be able to auto-load them. Drop-ins plugins are listed under “Drop-ins” in the plugins page and is activated by default. Remove them from this directory if you want to deactivate them.

Drop-ins available in WordPress and WordPress MS

  • advanced-cache.php – Advanced caching plugin
  • db.php – Custom database class
  • db-error.php – Custom database error message
  • install.php – Custom installation script
  • maintenance.php – Custom maintenance message
  • object-cache.php – External object cache

WordPress Multisite specific drop-ins

  • sunrise.php – Advanced domain mapping
  • blog-deleted.php – Custom blog deleted message
  • blog-inactive.php – Custom blog inactive message
  • blog-suspended.php – Custom blog suspended message
Posted in Plugins, WordPress | Tagged , , , , , , , , , , , , | Leave a comment

Cache data with WordPress Transient API

With WordPress transient API you can cache data in the database by giving it a unique identifier and an optional expire time after it will be deleted.

There are basically three functions in this API.

// Save data
set_transient($transient, $data, $expiration);

// Fetch data

// Remove data
  • $transient – a unique identifier
  • $data – the data to cache in the database
  • $expiration (optional) – seconds until the data should expire

The get_transient function will return false if the data has expired.

An example of how to use WordPress transient API

Lets make up a very basic example. Say that you have a widget that query the database for the 5 latest posts. To minimize the load on the database you can cache the results for a period of time. In this example we set the expiration time to 1 hour.

The php function can look something this.

// Get cached data, if any
if (false === ( $my_widget_query_results = get_transient('my_widget_query_results') ) ) {
    // If no data in cache, regenerate the data and save it
     $my_widget_query_results = new WP_Query('order=desc&post_count=5');
     set_transient('my_widget_query_results', $my_widget_query_results, 60*60*1);

// Then use the data as normal

Alternatively, you can skip the expiration parameter and use action hooks instead to delete the cached data. By doing it this way you will only regenerate the data when you actually need to. In our example, when a new post is published.

add_action('publish_post', 'remove_my_widget_query_results);

function remove_my_widget_query_results() {
Posted in Tutorials, WordPress | Tagged , , , , , , | 1 Comment

How to modify WordPress favorite actions menu

Since WordPess 2.7 there is a drop-down menu in admin that displays links to common actions. I don’t know the official name for it so I will just call it favorite actions menu.

WordPress Favorite Action Menu

WordPress Favorite Action Menu

The problem with this menu is that there are no options in WordPress to change the content of this menu (sure, there are of course plugins that can change this for you).

However, in this tutorial I will show you how to change this menu by adding some code to your themes functions.php.

This first example will show you how to remove the favorite actions menu completely. This is really simple. Just return an empty array.

function my_favorite_actions_menu($actions) {
	$actions = array();
	 return $actions;
add_filter('favorite_actions', 'my_favorite_actions_menu');

In the next example I will show you how to remove a menu item. To remove a menu item just unset that item. To find out which file to use in the unset function, just hover the mouse over the menu item and see what file it links to.

function my_favorite_actions_menu($actions) {
	return $actions;
add_filter('favorite_actions', 'my_favorite_actions_menu');

The last example will show you how to add a menu item to the plugins page. Worth mentioning is that the second parameter of the array is the capability. By using the capabilities we can choose which menu items each user role will see.

function my_favorite_actions_menu($actions) {
	$actions['plugins.php'] = array('Plugins', 'activate_plugins');
	return $actions;
add_filter('favorite_actions', 'my_favorite_actions_menu');
Posted in Tutorials, WordPress | Tagged , , | Leave a comment