The key to this is covered on the get_posts
codex page: Access all post data using the setup_postdata
function:
foreach ( $rand_posts as $post ) : setup_postdata($post);
Regarding the_date
, see the note about multiple instances on a page:
SPECIAL NOTE: When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use the Template Tag the_time() or get_the_date() (since 3.0) with a date-specific format string.
Related Posts:
- Why time functions show invalid time zone when using ‘c’ time format?
- Query between two meta values?
- Get posts by meta value with date
- Generate an Email address from that of the Post Author
- How to show Published date and/or Modified date
- How can I show many posts an author has per week?
- Time & Date on Post – Time Ago Custom Function
- How to remove Date from Meta Description on SERP?
- Sort Posts By Custom Field Date?
- How is the author’s name given a different color?
- Get the author meta adds now
- Conditional For get_the_author_meta
- Media attachment date and post date
- wpdb->get_var – count author posts, meta value
- Post Publish date not display on Umaya Child themes
- Check For get_post_meta on Author Archive Page
- How can i set media attachments to the author of the post or page for already existed posts with attachments
- Update post meta date always store 1970-01-07
- How do you update post date (year only) in a separate custom field?
- How to hide meta from search result only on pages?
- How can I prevent the post_modified column in wp_posts from being updated?
- How to update the ‘modified_time’ of a post ONLY when content is changed?
- Sorting meta box values by start- and enddate and all dates in between
- How do I retrieve the slug of the current page?
- Most efficient way to get posts with postmeta
- Get posts by meta value
- Explanation of update_post_(meta/term)_cache
- How to extract data from a post meta serialized array?
- How to save an array with one metakey in postmeta?
- WordPress is stripping escape backslashes from JSON strings in post_meta
- How can I get the post ID from a WP_Query loop?
- Unable to select an old date in wordpress
- How to get date for each post?
- Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
- Order by meta value or date?
- How to update_post_meta value as array
- Adding meta tag without plugin
- What’s the point of get_post_meta’s $single param?
- What is the different between an attachment in wp_posts and an attachment in wp_postmeta?
- How to edit a post meta data in a Gutenberg Block?
- Sanitizing integer input for update_post_meta
- post formats – how to switch meta boxes when changing format?
- Execute action after post is saved with all related post_meta records (data)
- Lack of composite indexes for meta tables
- Get a single post by a unique meta value
- if get_post_meta is empty do something
- How we get_post_meta without post id
- How get post id from meta value
- What is the code to get the download link for a product in WooCommerce?
- Safe to delete blank postmeta?
- advanced custom fields update_field for field type: Taxonomy
- update_post_meta not saving when value is zero
- Content hooks vs User hooks
- Get date of last update outside of loop
- Meta compare with date (stored as string) not working
- Ordering posts having multiple post-meta date fields
- Trying to get custom post meta through Jetpack JSON API [closed]
- How to update/insert custom field(post meta) data with wordpress REST API?
- WordPress Custom Query to show posts from last x years
- Restrict post edit/delete based on user ID and custom field
- get_post_meta returning empty string when data shows in the database
- publish_post action hook doesn’t give post_meta_data
- Remove WordPress.org Meta link
- Remove post meta keys
- How to access the post meta of a post that has just been published?
- Converting Unix timestamp to wordpress date
- Why is get_post_meta returning an array when I specify it as single?
- How to display date such “x ago”
- Date, Time, and Timezones
- How to update/delete array in post meta value?
- How to get all term meta for a taxonomy – getting term_meta for taxonomy
- Adding an assisting editor box to Post page
- How to set author for post AND post attachments
- How to remove published date from RSS feed
- delete unused postmeta
- Should I sanitize custom post meta if it is going to be escaped later?
- Add post meta based on another post meta value before publish post
- How do I retrieve multi-dimensional arrays from the wp_postmeta table, & display on a website?
- Permalinks using event date (year & month) instead of publication date
- Front-end update_post_meta snippet displays white screen?
- Save both current and new version of post meta
- Get Advanced Custom Fields values before saving [closed]
- Give extra post-meta to RSS feeds
- How to get meta value in wp_attachment_metadata
- WP REST API “rest_no_route” when trying to update meta
- Clean up output added via wp_head()
- List posts under meta_value heading
- Modify Date Format to German
- Why am I getting an infinite loop with have_posts?
- get_post_meta – get a single value
- delete value 0 in post meta [closed]
- Can I safely delete a record, manually, in the wp postmeta table?
- How to store post meta in an array?
- What action hook updates post meta?
- Can’t translate the post meta data (Date) in another language
- get_post_meta / update_post_meta array
- Ordering posts by anniversary using only day and month
- Serve visitor post time adjusted to their timezone
- adding a URL to a post meta
- Making WordPress author follow button, need missing ingredient