How to change author info link in blog post?

In this tutorial I am showing how you will change the default author link with custom link.

Changing The Link For All Authors

/**
 * Changing the author link for Blog post
 *
 * @copyright 2019 PaulChinmoy.com
 * @author Paul Chinmoy
 */
add_filter( 'author_link', 'paulc_change_author_link', 10, 3 );
function paulc_change_author_link( $link, $author_id, $author_nicename ) {
	global $post;

	if( 'post' == get_post_type( $post ) ) {
		return home_url( '/' );
	}

	return $link;
}

Changing The Link of a Specific Author

I’m changing the link for a specific author only. Check the PHP snippet at below:

/**
 * Changing the author link for Blog post
 *
 * @copyright 2019 PaulChinmoy.com
 * @author Paul Chinmoy
 */
add_filter( 'author_link', 'paulc_change_author_link', 10, 3 );
function paulc_change_author_link( $link, $author_id, $author_nicename ) {
	global $post;

	//* Changing the link of that author whose author ID is 23
	//* You will replace the ID 23 with your author ID
	if( 'post' == get_post_type( $post ) && 23 == $author_id ) {
		return home_url( '/' );
	}

	return $link;
}
This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.