You can get the latest post of an author adding the following code to your function:
$latest_post = get_posts( array(
'author' => $id,
'orderby' => 'date',
'numberposts' => 1
));
// Since get_posts() returns an array, but we know we only
// need one element, let's just get the element we need.
$latest_post = $latest_post[0];
Then modify your $output
, adding the data you need (specifically guid
for the permalink, and post_title
for the title), for example:
$output .= "<div id='bloggers_latest_post'>
<a href="https://wordpress.stackexchange.com/questions/95004/$latest_post->guid">$latest_post->post_title</a>
</div>"
Related Posts:
- How to display posts by current user/author in a custom page template?
- Get x recent posts by author?
- How to get single post by one author?
- Get Posts Under Custom Taxonomy
- How to show related posts by category
- Hook that get’s triggered when the author of a post is changed
- the_author() returns empty string
- get_children() Not Working with orderby Parameter
- Prevent Authors from viewing each others Posts
- How to get all posts related to particular category name?
- get all posts ID from a category
- Display Random Author with Details in Sidebar
- How to show list of posts by author and category?
- WordPress: How to get the current logged in author page URL?
- get comments and get posts in loop
- How to add editor’s name to entry meta byline?
- Different permalink for posts and authors
- How to know if get_posts() failed?
- Query posts distinct authors
- How to get previous 10 days post from a specific date – WP Query
- Restrict the Number of Posts an Author can Publish (over time)?
- Search posts by post author name
- Get the user type of an author
- Setting pagination for images attached to a post
- Find most recent authors
- Query only Posts from Both of Two Category?
- Show author post count in sidebar – Variable
- Get current users post URL?
- Get the author of the latest revision
- Filter posts by author and category simultaneously
- is there a better way of combining this?
- Custom Post Type & Author not associating, user post count is 0, api doesn’t return author in post objects
- Guest Author – How to modify my custom function code if the guest author URL will follow a particular pattern/format?
- Post author is changed to admin after his post is modified by admin
- WordPress get posts by date without query_posts
- Get all posts by post_author
- How can I control multiple editing of wordpress posts?
- Multiple authors for single post without plugin
- Limit number of posts a user can make per minute?
- Authors in menu, template list post by author
- Show the author’s count of total amount of posts assign to a custom taxonomy term
- Author must complete profile info before they can publish a post?
- WP rest api returns 404 only when author param is used
- Posts are not showing up on particular category
- How can I list random authors from current post category?
- get selected post using $_GET
- How Can i Get 5 Recent Post Title With Corresponding Link?
- Can I set and show “important” post in my blog?
- setup_postdata doesn`t seem ot be working
- Encrypt / Decrypt Post Title and Details
- Get Posts via Taxonomy Term Name with Space
- Get specific posts by ID in wordpress
- How can I show wordpress posts based on author?
- Automatically republish old posts
- Show info to author only
- get_next_post() and get_previous_post() return wrong posts
- Auto “expire” all of an authors posts on spcific date
- How to get the user meta data for a post?
- Limit posts per author role (excluding admin) in home page
- Get posts by name and taxonomy term
- Guest Author – How to display posts on /author/ archive page
- Inserting custom data to the_post() during loop
- How do I restart my loop with get_next_post()?
- How can I show many posts an author has per week?
- How to give capability (publish contributors posts) to author role?
- Get mixed category random posts
- WordPress not opening posts with only numbers if permalink is post_name
- Limit popular posts by days
- Why is querying posts messing up my pages?
- get_the_content(“more…”) returns full text
- Whitelist Author of Private Post
- Insert Content In Between Post Feed
- Show posts by a custom post author
- Post Loop Missing Most Recent Post
- Get Posts Under Custom Taxonomy
- Include sticky posts on the static page front page
- Get attachments for posts that belongs to a specific category
- Getting the current author (it has changed) of a post, not the original author
- Pagination with an array of post objects?
- Any way for get_next_post() to use the actual post order instead of publish order?
- Showing author page if user has no post
- Display Notification Bar on Header on Certain Post Count
- Posts loop displaying the same post data
- How to get posts from a current post’s month?
- How do I retrieve a users’ last 5 posts?
- obtain the author id given the post id
- How to get posts and comments amount per hour, per year and per month?
- While loop articles – if statement order
- Show comment number per author per day
- Count number of posts of current month
- How to Get Posts, Including Private Ones?
- Get all comments of author’s posts
- (solved) getting post author’s user role
- Change all author links in Blog roll
- Random posts from a pool of posts
- Conditional Tag for has post [closed]
- Display author’s name and avatar in post’s sidebar
- How to get post content from an array of ids?
- static landing page leading to author specific pages w/ “live” content
- Display Posts with template on a Page