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?
- How to get post creation date?
- Update post counts (published, draft, unattached) in admin interface
- Changing the post date and time with function
- 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
- featuring old articles without messing up with the archive
- 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?
- Human Time Diff, change mins to minutes
- Display custom post types by date field
- Hide comments awaiting moderation from user who submitted the comments
- How can I display a specific user’s first published post?
- Query All users that has post
- Can wordpress differentiate between added and updated posts?
- Fetch posts from current week (Sunday to Saturday)
- Limit number of posts a user can make per minute?
- How do I allow users to follow a post and then allow admins to email all users who have followed that post?
- wp_insert_post let users post to without login…broke
- Get user’s most published categories
- Allow anonymous users to post to my site for moderation
- How to set post expiration date and time and move the page to archive after expiration [closed]
- disable column on post and user list
- how to find user ids of all commenters in a post
- How to list users and their post amount?
- Is there any way to allow users to access content before it’s published?
- UberMenu list current user’s posts as menu items
- Display post from specific date
- Get random posts between specific dates / of specific age
- XML-RPC and post_date
- Create post for every user?
- Automatically republish old posts
- 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)
- 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?
- How to get post creation date?
- 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?
- How do i search post by jquery datepicker?
- 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?
- Adding post date to ACF field
- Add new post only in assigned category
- WordPress each user has each content for a page,how to do that?
- How can I set and update the the_date according to a custom field of the post
- Query post for today, if no post get the previous one
- Set post beginning date and final date
- 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?
- Count how many posts a user has viewed
- 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
- Show Custom Post From Logged In Author
- Delete old post with new post
- Last three posts not being put in order by date. How to fix this?
- 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?
- each user having category with their name and can add sub categories post in that category
- The post order is different for logged-in and non-logged-in users? [closed]
- the_time() cannot be placed correctly
- How to remove a date from wordpress post
- User submitted post
- how show post date for specific post?
- Exclude posts by date – related post
- Automatically select category based on user role
- Undefined Function Fatal Error with Shortcode [closed]
- 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
- How to get total posts count for each date?
- How to get orders that contains a product by date?
- Does WordPress Super User or Administrators can create and edit post and media on behalf of a user