Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Randomizing Post Links Outside of Loop – No Author or Date

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:

  1. Why time functions show invalid time zone when using ‘c’ time format?
  2. Query between two meta values?
  3. Get posts by meta value with date
  4. Generate an Email address from that of the Post Author
  5. How to show Published date and/or Modified date
  6. How can I show many posts an author has per week?
  7. Time & Date on Post – Time Ago Custom Function
  8. How to remove Date from Meta Description on SERP?
  9. Sort Posts By Custom Field Date?
  10. How is the author’s name given a different color?
  11. Get the author meta adds now
  12. Conditional For get_the_author_meta
  13. Media attachment date and post date
  14. wpdb->get_var – count author posts, meta value
  15. Post Publish date not display on Umaya Child themes
  16. Check For get_post_meta on Author Archive Page
  17. How can i set media attachments to the author of the post or page for already existed posts with attachments
  18. Update post meta date always store 1970-01-07
  19. How do you update post date (year only) in a separate custom field?
  20. How to hide meta from search result only on pages?
  21. How can I prevent the post_modified column in wp_posts from being updated?
  22. How to update the ‘modified_time’ of a post ONLY when content is changed?
  23. Sorting meta box values by start- and enddate and all dates in between
  24. How do I retrieve the slug of the current page?
  25. Most efficient way to get posts with postmeta
  26. Get posts by meta value
  27. Explanation of update_post_(meta/term)_cache
  28. How to extract data from a post meta serialized array?
  29. How to save an array with one metakey in postmeta?
  30. WordPress is stripping escape backslashes from JSON strings in post_meta
  31. How can I get the post ID from a WP_Query loop?
  32. Unable to select an old date in wordpress
  33. How to get date for each post?
  34. Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
  35. Order by meta value or date?
  36. How to update_post_meta value as array
  37. Adding meta tag without plugin
  38. What’s the point of get_post_meta’s $single param?
  39. What is the different between an attachment in wp_posts and an attachment in wp_postmeta?
  40. How to edit a post meta data in a Gutenberg Block?
  41. Sanitizing integer input for update_post_meta
  42. post formats – how to switch meta boxes when changing format?
  43. Execute action after post is saved with all related post_meta records (data)
  44. Lack of composite indexes for meta tables
  45. Get a single post by a unique meta value
  46. if get_post_meta is empty do something
  47. How we get_post_meta without post id
  48. How get post id from meta value
  49. What is the code to get the download link for a product in WooCommerce?
  50. Safe to delete blank postmeta?
  51. advanced custom fields update_field for field type: Taxonomy
  52. update_post_meta not saving when value is zero
  53. Content hooks vs User hooks
  54. Get date of last update outside of loop
  55. Meta compare with date (stored as string) not working
  56. Ordering posts having multiple post-meta date fields
  57. Trying to get custom post meta through Jetpack JSON API [closed]
  58. How to update/insert custom field(post meta) data with wordpress REST API?
  59. WordPress Custom Query to show posts from last x years
  60. Restrict post edit/delete based on user ID and custom field
  61. get_post_meta returning empty string when data shows in the database
  62. publish_post action hook doesn’t give post_meta_data
  63. Remove WordPress.org Meta link
  64. Remove post meta keys
  65. How to access the post meta of a post that has just been published?
  66. Converting Unix timestamp to wordpress date
  67. Why is get_post_meta returning an array when I specify it as single?
  68. How to display date such “x ago”
  69. Date, Time, and Timezones
  70. How to update/delete array in post meta value?
  71. How to get all term meta for a taxonomy – getting term_meta for taxonomy
  72. Adding an assisting editor box to Post page
  73. How to set author for post AND post attachments
  74. How to remove published date from RSS feed
  75. delete unused postmeta
  76. Should I sanitize custom post meta if it is going to be escaped later?
  77. Add post meta based on another post meta value before publish post
  78. How do I retrieve multi-dimensional arrays from the wp_postmeta table, & display on a website?
  79. Permalinks using event date (year & month) instead of publication date
  80. Front-end update_post_meta snippet displays white screen?
  81. Save both current and new version of post meta
  82. Get Advanced Custom Fields values before saving [closed]
  83. Give extra post-meta to RSS feeds
  84. How to get meta value in wp_attachment_metadata
  85. WP REST API “rest_no_route” when trying to update meta
  86. Clean up output added via wp_head()
  87. List posts under meta_value heading
  88. Modify Date Format to German
  89. Why am I getting an infinite loop with have_posts?
  90. get_post_meta – get a single value
  91. delete value 0 in post meta [closed]
  92. Can I safely delete a record, manually, in the wp postmeta table?
  93. How to store post meta in an array?
  94. What action hook updates post meta?
  95. Can’t translate the post meta data (Date) in another language
  96. get_post_meta / update_post_meta array
  97. Ordering posts by anniversary using only day and month
  98. Serve visitor post time adjusted to their timezone
  99. adding a URL to a post meta
  100. Making WordPress author follow button, need missing ingredient
Categories post-meta Tags author, date, date-time, post-meta
Search.php gets metadata from first post
Pagination for custom post types

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress