26 Aug 2009

Returns the URL of Author Archive Page OR Website

Returns the URL of Author Archive page OR Author website (if the Website field is set in the user’s profile) of the current post.

Add the following lines to your WordPress Theme’s template functions.php file (For example, functions.php file for a Theme named “default” would probably reside in the directory wp-content/themes/default/functions.php) or create it as a Plugin by filling the additional Standard Plugin Information:

add_filter('author_link', 'author_url');
	function author_url($url) {
		if (get_the_author_meta('user_url'))
			$url = get_the_author_meta('user_url');		

		return $url;
	}

Add within The Loop:

<span class="author vcard">
	by <a class="url fn n" href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>"><?php the_author(); ?></a>
</span>