WordPress Guest Author - How can I use custom fields to create guest
author link?
We are posting articles authored by guest authors. The guest authors will
not be logging in to the site.
I've added a function so that my guest authors name will appear in place
of the name of WordPress user who posted the article.. This function is
outlined here:
http://www.wpbeginner.com/wp-tutorials/how-to-rewrite-guest-author-name-with-custom-fields-in-wordpress/
Using this, I am able to change the name of the author to display the
guest blogger's name.. However the author link still points to the author
page of the WordPress user who posted the article.
So now I'd like to do something similar with the author link. What I would
like to do is for the author link to come from a URL that I will enter in
a custom field.
This is the code I'm using, but it's not working. The author link still
takes you to the author page for the WordPress user who posted the
article.
add_filter( 'the_author_posts_link', 'guest_author_link', 10, 3);
add_filter( 'get_author_posts_url', 'guest_author_link', 10, 3);
add_filter( 'the_author_link', 'guest_author_link', 10, 3);
add_filter( 'get_author_link', 'guest_author_link', 10, 3);
function guest_author_link($link, $author_id, $author_nicename) {
global $post;
$url = get_post_meta( $post->ID, 'guest-url', true );
if( $url ) {
$link = $url;
}
return $link;
}
Ideas?? Help...
Friday, August 16, 2013
WordPress Guest Author - How can I use custom fields to create guest author link?
Posted on 12:02 PM by Unknown
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment