The following query retrieves the oldest post of a specified user/author:
$user_id = 42; // or whatever it is
$args = array(
'posts_per_page' => 1,
'post_status' => 'publish',
'author' => $user_id,
'orderby' => 'date',
'order' => 'ASC',
);
$first_post = new WP_Query($args);
if ($first_post->have_posts()) {
$first_post->the_post();
// Now you can use `the_title();` etc.
wp_reset_postdata();
}
If you want to show the first post a specific user wrote (no matter what the post’s publish date is set/altered to), then you have to use 'orderby' => 'ID',
.
Related Posts:
- Is it possible to Schedule Attachments in WordPress?
- Query posts from current year
- featuring old articles without messing up with the archive
- Post: how to set created date after post has been published [closed]
- Need to display a Jan 1st post as the site’s front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc
- Bulk Post update_post_meta
- Query post for today, if no post get the previous one
- Get page ID of page that is set as the posts page
- Should we trust the post globals?
- How to get posts published between a date and today?
- Get the current post ID as a variable in Javascript
- Is post ID number always incremental n+
- Publish pending article from front end with a button?
- How to limit user to publish post per day and per role?
- How to know if get_posts() failed?
- Restrict the Number of Posts an Author can Publish (over time)?
- Duplicate posts
- Looping through posts per category gives same posts for each category
- How to show posts rank based on custom field value
- At my posts archive page, outside the loop, get_the_id() returns the top most post’s ID
- How do I create Comma Separated list of attached image ids?
- How to display an icon when a new post is published and then remove it when a specific time past?
- Can wordpress differentiate between added and updated posts?
- How can I get all posts data from within a paginated search result?
- publish_post conflicts with save_post
- posts_per_page doesnt work
- Notification to Admin or Author upon new post [duplicate]
- Only display posts after current date
- What differences are there between a Privately Published post and a Draft post?
- pre_get_posts query between 2 dates (date stored in custom post meta)
- WP_Query Authors OR Categories
- Post-ID in url differs from $post->ID
- Why is my Blog Page ID == First Post ID?
- Print a message if excerpt is empty after posts have been publish/update!
- Query get post,how to add comment box
- Check if checkbox is marked on publish/update post
- Search results posts_orderby and ID
- Prevent scheduled post being published if date/time is past current date/time
- get query() without post content?
- posts_per_page option limits the number of Gallery items
- transition_post_status hook doesn’t have any POST data when publish with Gutenberg [closed]
- Worpdress function for difference dates
- How to get a post’s content? [closed]
- Dynamically switch template on click
- Get all custom post types excepted some…
- Get all comments of author’s posts
- Why I can not I use the variable outside my function?
- Counter is skipping post when I still want it visible [closed]
- Do not show children of a category
- How to get all post_parents of a post?
- Run query_posts if SESSION is empty?
- Stop wordpress from creating empty/null entries
- What date to use as a post date? date_gmt or modified_date_gmt
- How to give classname to post if post has no content?
- Assigning Two Different Post Dates For Single Post
- How to retrieve certain number of images from a wordpress post?
- How can I tell if a post has been published at least once?
- Send email for pending post
- Add “Posted on” to post date
- WP_Query custom field pass the post id
- How to convert query sql to shortcode in wordpress?
- Some doubts about how the loop work (trying debugging it)
- Date is wrong on ‘all posts’ page
- Widget to show posts in the sidebar basing on its IDs
- Making posts permalinks consistent numbers
- Adjust the order for returned posts
- How to get post id of last approved comment?
- Trim posts from WP-Query?
- Trying to exclude custom posts based on date, while sorting by custom field
- Post date automatically +100 years into the future
- how to add tags to post in the Loop?
- Merge get_comments & get_posts into a single query
- How to optimize posts query in wordpress
- Change Old WordPress Post Date Year
- WordPress doesn’t save or publish new posts
- Reuse old post ID for new post after deleting post
- How to search through “post title” and “tags” using WP_Query?
- Get post attachment with post id
- Set a post expiration and delete a post when expirate
- How publish post from pending status
- Display Updated Date Instead of Published Date
- I have two post types in the same query, how can I use CSS to select only one post type?
- How do you update post date (year only) in a separate custom field?
- How to hide meta from search result only on pages?
- How do I display posts ordered by a date custom field?
- Numbering author posts in posts query
- How to run select query of post with category and tags?
- Get from the dashboard the ID of the current post being edited
- Custom Select Query pagination not working properly
- Sort / Filter Queries
- I want to send push notification just after publish a new post
- How to display an icon when a new post is published and then remove it when a specific time past?
- Display the latest post from some selected authors
- Displaying Results From Custom Taxonomy Query
- Display metabox with date
- Get first comment link on the post itself
- Make division in post_query?
- Display one post randomly from category on home page
- Custom post page has attributes of latest post [closed]
- Can I get custom post items in select box (dropdown)