In your sample code the $latest_posts is an instance of WP_Query class.
If you want to get the latest post’s date, you should do this:
$latest_posts = new WP_Query( $args );
$last_date="";
if ( $latest_posts->have_posts() ) {
$latest_posts->the_post();
$last_date = get_the_date();
}
return $last_date;
Related Posts:
- Compare date of user’s last posts
- How to get posts published between a date and today?
- Update post counts (published, draft, unattached) in admin interface
- How to Display a List of Users Who Have Made at Least 1 Post?
- Find out who deleted a page or post?
- Is it possible to Schedule Attachments in WordPress?
- using wp_update_post on save_post
- User-Specific Timezones? Hack? Plugin?
- WordPress: How to get the current logged in author page URL?
- disable password protected page for logged users
- How to put last edited entry on top of the blog-post list?
- Query posts from current year
- Force “Submit to review” when a post is updated
- Update existing post dates to random dates
- Overview with latest edited posts and pages
- Navigation link to specific user page
- Get how many days since last post of the current user
- How to display an icon when a new post is published and then remove it when a specific time past?
- How to output comments number of a post per day?
- Hide comments awaiting moderation from user who submitted the comments
- How can I display a specific user’s first published post?
- Can wordpress differentiate between added and updated posts?
- wp_insert_post let users post to without login…broke
- Allow anonymous users to post to my site for moderation
- disable column on post and user list
- How to list users and their post amount?
- UberMenu list current user’s posts as menu items
- Display post from specific date
- XML-RPC and post_date
- count the total number of comments the user has received for his published posts
- Replace ‘published on date’ with ‘modified on date’ on Posts
- pre_get_posts query between 2 dates (date stored in custom post meta)
- If modified on same day, show only time
- How to allow logged in users to post anonymously
- Update all comments time to random dates?
- How to verify wp user password by sql query in wp? [closed]
- How can i delay reading posing in 3days for not logined user?
- Encountering “Wrong nonce. Action prohibitied.” when trying to alter User Role and unable to Post via WP Admin
- date issue with category post retrival
- How to get date of post when using wp_get_recent_posts()?
- How do I manage my users post before publish?
- Worpdress function for difference dates
- Gather posts into a cart/lightbox and share with another user
- Changing default WP-Site creation date
- Add field to user meta table in database when link is clicked
- Hide comments and posts posted by other user
- Automatically create a default set of posts for each new registered user
- How to get posts published on the latest date?
- Display a list of users who have viewed the post you are viewing
- What date to use as a post date? date_gmt or modified_date_gmt
- Echo Text If User Is Logged in But NOT the Author of post
- How to update all posts at once?
- Deleted a user with administrator rights. Now all the data/content/images are lost. how to recover them back
- Assigning Two Different Post Dates For Single Post
- Using system date format
- Add “Posted on” to post date
- Auto update post title and slug when post status is changed
- Show number of posts by logged in user
- wp_query if have posts show date but not in loop
- Retrieving posts by their date and category
- Retrieve data from post meta meta_key having ‘_product_fq_image’ while having author_id and post type is PRODUCT
- Date is wrong on ‘all posts’ page
- Getting an extra post’s meta data?
- Cannot select certain authors for posts after import
- Plotting posts on a graph
- Post date automatically +100 years into the future
- How to limit post (Exception pages) for current user in each role in front end?
- Change Old WordPress Post Date Year
- My website is showing today’s date instead of published date since db migration to a new wordpress
- How can I change the date format of the revision list?
- 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
- Set a post expiration and delete a post when expirate
- Display Updated Date Instead of Published Date
- Is there a way to save different data when USER interacts with the same POST?
- How do you update post date (year only) in a separate custom field?
- How to display particular categorie’s post which associated to specific user?
- WordPress Delete Users from backend doesn’t work
- Allow users to post their videos to my wordpress website?
- How to hide meta from search result only on pages?
- How do I display posts ordered by a date custom field?
- Query post for today, if no post get the previous one
- Skip posts, but keep posts per page
- User rank in wordpress post
- How to display an icon when a new post is published and then remove it when a specific time past?
- Allow users to create their own page/s
- Get current user array with post string
- My posts section for logged in user
- How to organise post by category and date
- Display metabox with date
- Delete old post with new post
- How to change text (date) in post base on the day
- How to handle dates, trying to calculate time since a post
- How to display a certain template element only for posts published within certain time range?
- The post order is different for logged-in and non-logged-in users? [closed]
- the_time() cannot be placed correctly
- how show post date for specific post?
- Exclude posts by date – related post
- Automatically select category based on user role
- How to allow Contributors to edit their own posts, whilst still needing to be reviewed by an admin?
- Allow users to edit post without logging in