I've just upgraded to WP 3.0 and I've added a custom metalink for guest authors. After reading this post, I tested replacing my author link - it almost works.
This is my code:
// Replace author name with guest author name if populated
add_filter( 'the_author', 'guest_author_name' );
add_filter( 'get_the_author_display_name', 'guest_author_name' );
add_filter( 'the_author_link', 'guest_author_link', 10, 3);
add_filter( 'get_the_author_link', 'guest_author_link', 10, 3);
// Function to replace author name with guest author, if guest author has value
function guest_author_name( $name ) {
global $post;
$author = get_post_meta( $post->ID, '_author_name', true );
if ( $author )
$name = $author;
return $name;
}
function guest_author_link( $link, $author_id, $author_nicename ) {
global $post;
$url = get_post_meta( $post->ID, '_author_url', true );
if( ($author_id==1) && ($url) ) {
$link = $url;
}
return $link;
}
I'm able to replace the name, but the link sill points to the posts original author (wordpress author). I would like replace the link to the URL entered for the guest author.
Another "problem" is if I want to see all posts from this guest author. How do I list those posts if the user is not registered as a user? My first thought is creating a custom wp-query - but it would be sweet if I could use one of my existing templates for listing articles.