Advertisements

get_author_posts_url

Definition:
function get_author_posts_url($author_id, $author_nicename = '') {}

Retrieve the URL to the author page for the user with the ID provided.

Parameters

  • $author_id
  • $author_nicename

Return values

returns:The URL to the author’s page.

Defined filters

  • author_link
    apply_filters('author_link', $link, $author_id, $author_nicename)

Source code

function get_author_posts_url($author_id, $author_nicename = '') {

	global $wp_rewrite;

	$auth_ID = (int) $author_id;

	$link = $wp_rewrite->get_author_permastruct();



	if ( empty($link) ) {

		$file = home_url( '/' );

		$link = $file . '?author=' . $auth_ID;

	} else {

		if ( '' == $author_nicename ) {

			$user = get_userdata($author_id);

			if ( !empty($user->user_nicename) )

				$author_nicename = $user->user_nicename;

		}

		$link = str_replace('%author%', $author_nicename, $link);

		$link = home_url( user_trailingslashit( $link ) );

	}



	$link = apply_filters('author_link', $link, $author_id, $author_nicename);



	return $link;

}

1172

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: