How to remove WordPress admin bar

WordPress 3.1 introduces a new admin bar which is located at the top of your site. Some people like the admin bar and some don’t. Here are two ways of removing it. One by adding code to your themes functions.php and one by simply tick a checkbox from your profile page.

Put this code in your themes functions.php to remove the admin bar.

add_filter( 'show_admin_bar', '__return_false' );

You can also extend this code by adding conditional statements to further control when to show or hide the admin bar. This example hides the admin bar when viewing the site.

if(!is_admin()){
add_filter( 'show_admin_bar', '__return_false' );
}

This example hides the admin bar for non admin users.

if(!current_user_can('add_users')){
add_filter( 'show_admin_bar', '__return_false' );
}

Of course you can combine them as you want. Check out WordPress roles and capabilities and conditional tags for more ways of controlling this.

The other way of removing the admin bar is from your profile page. From here you can choose to remove the admin bar completely or show it when viewing the site or when in dashboard.

WordPress Show Admin Bar

WordPress Show Admin Bar

Update 2011-03-21
Add the following code to your themes functions.php if you want to hide the admin bar option from the user profile.

<?php
add_action( 'admin_head', 'hide_admin_bar_settings' );
function hide_admin_bar_settings() {
?>
	<style type="text/css">
		.show-admin-bar {
			display: none;
		}
	</style>
<?php
}
Posted in Tutorials, WordPress | Tagged , , , | 6 Comments

How to disable internal pingbacks in WordPress

You have probably noticed that when you link to a post on the same site you will get a pingback on the old post with a link to your new post. If you for whatever reason wants to get rid of those internal pingbacks, simply put the following code snippet in your functions.php. Note that you will still get pingbacks from other sites.

function disable_internal_pingbacks( &$links ) {
	$home = get_option( 'home' );
	foreach ( $links as $l => $link )
		if ( 0 === strpos( $link, $home ) )
			unset($links[$l]);
}

add_action( 'pre_ping', 'disable_internal_pingbacks' );

If you don’t like writing or adding code to your functions.php, you can instead install the No Self Pings plugin from WordPress plugin directory.

Posted in Tutorials, WordPress | Tagged , , , | 8 Comments

Ultimate Guide to Update WordPress [Infographic]

In one of my previous blog post I wrote about how to hide the WordPress update message for client who should not do the updates themselves. However, if you have clients that will do the updates WPBeginner have put together a great infograph about the steps you should take when updating a WordPress site.

Ultimate Guide To Upgrade WordPress

Ultimate Guide To Upgrade WordPress

If you have any other infograph or guide about the steps to take when updating a WordPress site, please write a comment about it.

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

How to hide the WordPress update message

On aspect when developing sites for clients is how to handle updates of WordPress and plugins. Should you let your clients do this themselves or should you offer that as a service?

WordPress has a built in function that will let you know when there is a new version that you can update to. A message like the one in the image will be displayed to the user prompting to update.

WordPress Update Message

WordPress Update Message

If your clients are doing the updates themselves, this is a great function for reminding them. However, if you are doing the updates for the clients this can cause trouble for you if they click on the message and attempt to do the update. Of course they can manage to complete to update successfully but sometimes they can get in to trouble and have forgotten to do a proper backup.

There is a easy solution for this. Just put this simple code in your functions.php and the update message will be hidden.

function hideUpdateNag() {
	remove_action( 'admin_notices', 'update_nag', 3 );
}
add_action('admin_menu','hideUpdateNag');

You can optionally put this code with a condition so that the update message will only be shown to the site admin or other user roles depending of the if-statement in the code snippet below.

function hideUpdateNag() {
	remove_action( 'admin_notices', 'update_nag', 3 );
}
if ( !current_user_can('activate_plugins') ) {
	add_action('admin_menu','hideUpdateNag');
}
Posted in Tutorials, WordPress | Tagged , | 5 Comments

Infographic – The anatomy of a WordPress theme

Yoast.com by Joost de Valk has put together a great infographic about the anatomy of a WordPress theme. It gives you a overview of how a WordPress theme works and which files does what.

The anatomy of a WordPress theme

The anatomy of a WordPress theme

Source: Yoast.com

Posted in Infographics, WordPress | Tagged , , | 2 Comments

Review of Smashing WordPress: Beyond the Blog

I recently came across a WordPress book that I just had to buy. It is written by Thord Daniel Hedengren, or TDH as he is called in the blogosphere, which might be Sweden’s biggest profile in the WordPress community.

Smashing WordPress: Beyond the Blog

Smashing WordPress: Beyond the Blog

Smashing WordPress is published in February 2010 with Wilys and is a full colored book with about 300 pages. As you probably figured out by the title, this book is a part of the Smashing Magazine series of books.

Although the book was written before the release of WordPress 3.0, which was a major upgrade to WordPress, the book is still worth buying because it gives the reader a great overview of what you can do with WordPress and all examples in the book should still be valid.

Smashing WordPress is divided in five parts which together covers the basics when it comes to developing sites on WordPress CMS.

The books table of content

PART I: THE WORDPRESS ESSENTIALS
Chapter 1: Anatomy of a WordPress Install
Chapter 2: The WordPress Syntax
Chapter 3: The Loop

PART II: DESIGNING AND DEVELOPING WORDPRESS THEMES
Chapter 4: The WordPress Theme Essentials
Chapter 5: The Child Theme Concept
Chapter 6: Advanced Theme Usage

PART III: DEVELOPING WORDPRESS PLUGINS
Chapter 7: Anatomy of a WordPress Plugin
Chapter 8: Plugins and functions.php

PART IV: BEYOND THE BLOG
Chapter 9: WordPress as a CMS
Chapter 10: Uncommon WordPress Usage
Chapter 11: Essential WordPress Plugins

PART V: WORDPRESS TOOLBOX
Chapter 12: Design Trickery
Chapter 13: Extra Functionality
Chapter 14: Fun with Images
Chapter 15: Integrating the Social Web

Part 1 of the book starts with explaining the basic installation and what to think about when it comes to security. Moving on, we get to learn about the WordPress syntax which is basically PHP functions that you can use in your themes to make WordPress do the things you want. This first part ends up with a walkthrough of The Loop which is a PHP query that tells WordPress what content we want to display.

Part 2 takes us into the world of WordPress themes. A theme in WordPress is the PHP files that actually control what content goes where and how it should be presented. One very important aspect of theme development is the concept of Child Themes. This is particularly interesting if you want to base you theme on another theme as a foundation. If so, you should really look into this concept. Part 2 ends up with some advanced theme usage like individual styling techniques, mastering action hooks and other cool stuff that will help you with creating that wonderful WordPress site.

Part 3 walks us through how to develop WordPress plugins. First we get to learn all the important basics that build up a WordPress plugin then this part of the book finish off with a short explanation on when to use the theme file functions.php and when to use a plugin.

Part 4 takes you beyond the blog and proves that WordPress can be used in many other types of site. We will also get introduced to some plugins divided in several categories that can help us do things without writing any code ourselves.

Part 5 is the last part of this book and it will show off some great tricks on what you can do, like placing ads in the loop and how to work with images. Finally, the whole book ends up with how to integrate our site or blog to the social web.

To sum up this short review of Smashing WordPress: Beyond the blog, I would say that it is a great and well written book which is easy to follow. In my opinion it is a book for people with a low to intermediate level of experience with WordPress. The book covers all main aspects of WordPress and will work as a great foundation for you to get started to make great blogs as well as sites.

You can buy Smashing WordPress: Beyond the blog at Amazon or if you live in Sweden you can also buy it at Adlibris, Bokus and at Bokia.

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

How to add a thumbnail to your WordPress RSS feed

To make sure your RSS feed stands out in the crowd you can make it look a little bit nicer by adding a thumbnail to it. The following code should be placed in functions.php and it adds a thumbnail to both to the full RSS feed and also to the excerpt version if you choose to use that one.

function rss_post_thumbnail($content) {
	global $post;
	if(has_post_thumbnail($post->ID)) {
		if (get_option('rss_use_excerpt')){
			$content = '<p>'.get_the_post_thumbnail($post->ID).'</p>'.get_the_excerpt();
		}else{
			$content = '<p>'.get_the_post_thumbnail($post->ID).'</p>'.get_the_content();
		}
	}
	return $content;
}

add_filter('the_excerpt_rss', 'rss_post_thumbnail');
add_filter('the_content_feed', 'rss_post_thumbnail');
Posted in Tutorials, WordPress | Tagged , , , , | Leave a comment

Make a custom admin footer text

When creating a site for a customer you might want to brand WordPress backend.

At the bottom of the admin interface there is the following text.

Thank you for creating with WordPress. | Documentation | Feedback

To change this text simply add this function in the functions.php file located in you theme folder. If this file doesn’t exist simple create it.

function custom_footer_admin () {
	echo 'Add you custom footer text here';
}
add_filter('admin_footer_text', 'custom_footer_admin');
Posted in Tutorials, WordPress | Tagged , , , , | 1 Comment

How to increase WordPress memory limit

Sometimes during upgrade of WordPress or when you install a plugin you can experience Allowed memory size of xxx bytes exhausted.

It usually looks something like this:

Fatal error: Allowed memory size of 33673532 bytes exhausted (tried to allocate 2358947 bytes) in /home2/xxx/public_html/wp-includes/plugin.php on line xxx

WordPress comes with a default memory limit of 32MB. So if you encounter this error try increase the memory limit. Increase the memory limit in steps of 8MB.

There are a few ways of solving this problem and which solution that works for you depends on your host.

php.ini

If you have access to your php.ini file, find this line and increase the number.

memory_limit = 32M

.htaccess

In your .htaccess file, increase the value or add this line if you don’t have it already.

php_value memory_limit 32M

wp-config.php

It is also possible to increase the memory from wp-config.php file.

define('WP_MEMORY_LIMIT', '32M');

If none of the above solutions work for you, ask your host.

Remember that you should never change a WordPress core file. If you do, these changes will be removed each time you upgrade to a new version of WordPress.

Posted in Tutorials, WordPress | Tagged , , | 1 Comment