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

Display post details by post ID

You can use get_post for that

Example:

<?php
$post = get_post($id); //assuming $id has been initialized
setup_postdata($post);

// display the post here
the_title();
the_excerpt();
the_post_thumbnail();

wp_reset_postdata();
?>

Related Posts:

  1. How to get the post content from a category on my homepage
  2. Display post’s description and caption
  3. get posts based on category and post meta
  4. How do I get posts by multiple post ID’s?
  5. What does setup_postdata ($post ) do?
  6. Query for custom post type? [closed]
  7. setup_postdata() does not seem to be working?
  8. Regenerate Slugs From Title of Posts
  9. get_posts – get all posts by author id
  10. Why get_posts are only showing five posts (retrieved by assigning a category to them?
  11. Exclude Current Post from Recent Posts Loop
  12. WordPress get_posts by category
  13. get_post random and order by not working
  14. Alternative to get_posts() due to multithreading cache crash
  15. meta_query: using BETWEEN with floats and/or casting to DECIMAL
  16. How to get current post ID in quick edit callback
  17. get_posts with meta_compare=’LIKE’ not working
  18. How to restore deleted pages/posts?
  19. Sort “get_pages” by menu order not ordering
  20. get posts based on meta value of the author
  21. date_query not returning some posts in date range
  22. Get the exact SQL query that get_posts() generated
  23. How do you get posts by meta_query using the JSON API plugin?
  24. Why favour the standard WP loop over iterating over (new WP_Query())->get_posts()?
  25. Query posts ordering by title, but ignore ” and special characters
  26. get_posts inside cron
  27. get_posts not honoring post_status
  28. get_posts returning empty array
  29. get_posts only children from certain parents
  30. Problem with get_posts, tax_query and counting the number of posts
  31. get_posts cannot grab from specific category
  32. WP Query post meta value
  33. Filtering custom post type query
  34. Check If posts exist in custom post type category, outside of loop
  35. Get posts by meta value with date
  36. data returned from get_post($postId) have different keys than wp-json/wp/v2/posts/{postId}
  37. Order posts according to user defined order for meta values?
  38. How to limit get_posts()?
  39. meta_query date and time comparisons
  40. get_posts from post x(offset=>x) to end
  41. With get_posts(), how can I put a category as a variable
  42. What’s the difference between “get_posts” and “wp_get_recent_posts” when used with “setup_postdata”?
  43. Serialized array, grab specific posts with meta_key/meta_value[0]->is_featured
  44. How do I combine these 2 queries
  45. get_posts gives different result than wpdb->get_results
  46. Increase the page size of the WordPress REST API
  47. How to generate a list of posts published on current day?
  48. Trouble using get_post
  49. Ordering posts by metadata
  50. Cache Get_posts
  51. Get latest posts from multiple categories
  52. get_posts() returns all posts rather than the ones specified with ‘post_author’ =>
  53. Query random post from different categories
  54. Get_Posts, only if in both categories
  55. Remove posts from query for events whose start date has passed
  56. Posts not showing in correct Alphabetical or ID order when using get_posts / orderby but only on production server
  57. get_posts() excluding all children of a specific post/page
  58. Secondary Query Is Breaking Main Query
  59. If clauses in get_posts query
  60. var_dump and print_r cause white screen
  61. `get_posts()` ignore my custom post
  62. excluding current post from get_posts
  63. How to query posts to include specific pages of one post type, and all pages of another post type?
  64. Only retrieve posts where post_excerpt has been filled out
  65. Can I use numberposts=-1 and offset together when using get_posts()?
  66. Ordering posts in get_posts
  67. I don’t arrive to do order_by title when i have a conditionnal year in a request
  68. How can I display a single post link, based on title sample and change monthly?
  69. get_posts() doesn’t consider user permissions
  70. Meta query: get posts with value in a multidimensional array
  71. Get posts inside Get terms problem
  72. If meta key exists in get posts function otherwise create it
  73. Better way to list links with different meta values using same meta key?
  74. Ho to add get_relative_date and post_except to this get_latest_post query?
  75. How to update all posts but the current one (post__not_in not working?)
  76. Include sticky posts on the static page front page
  77. Only showing the_date and the_excerpt for first entry in get_posts
  78. get_post_meta slowing down my page load (in a plugin)
  79. get_posts() not working in functions.php
  80. Query Problem in getting top viewed posts
  81. get_posts in meta box dropdown not showing latest posts
  82. get_posts not working as expected
  83. Is it possible to retrieve a post and its metadata at the same time?
  84. Get all pages and posts with get_pages() or get_posts()
  85. Getting only a specific post type with get_post?
  86. What is the p parameter in a get_posts() parameter array?
  87. Exclude post format from get_posts
  88. Memory issue with get_posts( ) function
  89. get_posts() using an array of post ids [closed]
  90. Get only used meta_values
  91. Iterate over get_post_meta() result
  92. Look up all posts by status or meta value – performance difference
  93. How can I show the author’s latest post with title?
  94. Inserting post content into pages when using custom taxonomies
  95. Unique Problem with the php date and get_posts
  96. get the post_date of ID
  97. Output meta into arrays
  98. Get posts by language in Polylang plugin
  99. Query get_posts by level depth
  100. Get posts in between specific ID’s
Categories get-posts Tags frontpage, get-posts, post-meta
How do I Import / Upload Files with jQuery AJAX?
Animated GIF on WordPress posts? [closed]

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