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’s description and caption

Something like this should get you close (untested):

<?php
    foreach($my_posts as $post){
        $thisPostId = $post->ID;
        $thisPost = $get_post($thisPostId);
        $thisPostTitle = apply_filters('the_title', $thisPost->post_title);
        $thisPostThumbnail = get_the_post_thumbnail($thisPost);
        $thisPostContent = apply_filters('the_excerpt', $thisPost->post_excerpt);

        $data[] = array(
            "id" => $thisPost,
            "title" => $thisPostTitle,
            "image" => $thisPostThumbnail,
            "content" => $thisPostContent
        );
    }
?>

Related Posts:

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

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