0
votes

I am trying to display the post title URL of a post by an Author.

I need to display this in 2 places

1) Dashboard (only logged in user can see this)

2) Public info on their public profile page

///

1) Dashboard

So the user will be logged for Dashboard so I am thinking I could get the Post URL based on the currentuser ID and echo it on the page?

I can figure out how to get the current user ID

get_currentuserinfo();
$userID = $current_user->ID;

but not sure how to get / echo the post title from there.

2) Public Info So this will be in a public profile page. I want to display the Post URL for the Authors profile page that we are looking at.

On this profile template I am already displaying the user name like this

<?php 
echo get_queried_object()->display_name;
 ?>

So thinking I could somehow get the post URL based on this display name or another object I could query?

2 seperate questions in a way , but looking for some help in how to display this information.

Cheers

1

1 Answers

0
votes

It sounds like you want to use get_author_posts_url($userID).

This will take you to (by default) site.com/author/author-nicename/ and using the author.php template it will display posts by that author.

You need to echo this value, btw, like so:

<a href="<?php echo get_author_posts_url($userID); ?>"><?php echo $display_name; ?></a>