0

My header looks like this.

enter image description here

I chnaged my author base from "author" to "user"

So the user profile url looks like this.

http://example.com/user/username

What is the php function to get this url.

I'm using like this

<a href="<?php echo esc_url( home_url( '/' ) ); ?>user/<?php echo $current_user->user_login ?>"><?php echo $current_user->user_login ?></a>

Its working. But its hard coded.

Is there any other php function to get the url?

1

For all author meta details you can use the_author_meta

http://codex.wordpress.org/Template_Tags/the_author_meta

<a href="<?php the_author_meta('user_url', $current_user->ID);?>"><?php the_author_meta('display_name', $current_user->ID);?></a>

If its for user meta use get_user_meta

http://codex.wordpress.org/Function_Reference/get_user_meta

<a href="<?php echo get_user_meta($current_user->ID, 'user_url');?>"><?php echo get_user_meta($current_user->ID, 'display_name');?></a>
0

Do you search for get_author_posts_url( $author_id, $author_nicename )?

Note, you need the author ID, not the login name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.