Numbering your comments, pingbacks, trackbacks or all

Since WordPress 2.7 exists an API for the comment area. Thereby you can purge the PHP-portion within comments.php. Jean-Baptiste shows a simple solution to count comments. This solution is very well known and get used pretty much since the first release of WordPress. But if you like to have a filter, which counts only the trackbacks or only the comments, then this solutions is worthless. Besides that, the How To is pretty poor and PHP-rookies could have troubles with it.

Relating to this and because of many questions about this topic I show you two simple functions, which you insert in your functions.php of your theme. Normally they get used as output in your comments.php.
Continue reading …

Comment And Ping Count In WordPress 2.7

The comment area changed a lot in WordPress 2.7. A good reason to check your comments.php and make some changes to it. Especially I like to seperate the comments from Ping- and Trackbacks. Matt shows in an excellent tutorial how to do it: Separating Pings from Comments.

But I didn't like one thing in this tutorial. To show the total count of your comments without Pings/Trackbacks, he writes following function in functions.php:
Continue reading …

Add Avatar To WordPress Default

Avatars are popular as identification and with the service Gravatar it is largely used in the comment area of different applications.
WordPress allows the user some basic settings. For example loading a default or generated Avatar, if the commentator doesn't have one.
Various themes have a standard Avatar to match the design. But even here there is a nice solution via a hook, which enables to add an avatar in the list of your backend to make a selection quite simple. In the following I would like to show with a short and simple code snippet how to add 2 new avatars to the array of WordPress.

addavatar

You have to add this little function to functions.php of your theme and it will add 2 Avatar from your folder images of your theme directory. I suggest, that the Avatars have a size of 60 pixel.

/**
 * add a default-gravatar to options
 */
if ( !function_exists('fb_addgravatar') ) {
	function fb_addgravatar( $avatar_defaults ) {
		$myavatar = get_bloginfo('template_directory') . '/images/avatar.gif';
		$avatar_defaults[$myavatar] = 'people';

		$myavatar2 = get_bloginfo('template_directory') . '/images/myavatar.png';
		$avatar_defaults[$myavatar2] = 'wpengineer.com';

		return $avatar_defaults;
	}

	add_filter( 'avatar_defaults', 'fb_addgravatar' );
}

Is the theme active, you will have the 2 new Avatars available in your list.