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

Create Array from custom post type to display a slider

You are using the_post_thumbnail() which will echo the actual thumbnail. You should use get_the_post_thumbnail() if you want the value to be returned, not echoed.

So, change:

$slide_img = the_post_thumbnail();

To:

$slide_img = get_the_post_thumbnail();

You should also, as Matt points out, make sure you are using the correct meta field names and check if the values are set correctly.

Related Posts:

  1. Grossly inefficient wordpress loops!
  2. Automatically adding meta data to posts or multiple query help
  3. Displaying custom posts only if custom meta box’s date is not expired
  4. get_template_part() – post-meta not working?
  5. Create a random unique 6 digit number as custom field for custom post type
  6. My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
  7. Meta Key Value in current-user-only loop
  8. Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
  9. How to retrive Custom Post Type Meta Fields in Custom WP_Query
  10. How can I loop at a Specific Taxonomy from a custom post type?
  11. Custom archive page for custom taxonomy and pagination issue
  12. Custom meta fields not showing up in WP_Response Object via custom endpoint
  13. Staggering featured post using ‘sticky’
  14. get_post_meta for Custom Post Type ( CPT )
  15. How to create content automatically when a post is published?
  16. why get_post_meta is returning 0?
  17. A to Z List of Custom Post Type in three columns
  18. Custom post type, organized by categories
  19. post meta parameter in post custom-post-type endpoint with restapi
  20. How do I set all of a particular post meta to a value within the custom post type I’m in?
  21. What’s the WP way to load remaining custom posts?
  22. Update postmeta Parent when post_status child change
  23. WP Query with categories only shows one post and ignores the category
  24. What to and how to proceed with CPT to make DB small and efficient?
  25. Metabox not show in categories custom post type cmb2
  26. WordPress request fiter order by related post’s post_title
  27. Post ID randomly printing on page
  28. A custom post within a custom post
  29. Display Custom Taxonomy Alphabetically
  30. Full Custom Post Type List Organised by two Taxonomies
  31. Displaying Custom Posts on a Page
  32. Shortcode not working with post counter
  33. Problem: wp_query outputs all images on site
  34. Display post content with respect to its title?
  35. Update database from Quick Edit according to Checkbox state of Custom Post Type
  36. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  37. Get custom post type’s fields in a while loop as variables
  38. Custom Post Type within the Loop on Homepage (Page Template)
  39. Dynamic Custom Fields
  40. The loop seems stuck to a single (now deleted) post
  41. Show Custom Post Type meta boxes only on Page Edit
  42. Posts per row on archive page (custom post type)
  43. How do I know the ‘meta_key’ for ordering my custom post type
  44. Custom filter function not working with Custom post type
  45. Limit the post for differents custom post type in the same wp_query
  46. Custom Theme With Custom Loops
  47. Custom Post Types strange pagination problem
  48. Custom post type conditional in loop
  49. Importing Data from a Non-WordPress database, into WP
  50. Listing all term items alphabetically / sorting loop
  51. Getting thumbnails of a custom posts featured images in a page-templates metabox
  52. Display related custom taxonomy posts in sidebar
  53. List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
  54. Remove Post Custom Meta Box
  55. pagination not working for category.php (custom post types in categories)
  56. Can’t publish custom post type – “You are not allowed to edit this post.”
  57. Only show posts with date of today or in the future (i.e don’t show past posts)?
  58. How do I control the output of a custom post type in the loop?
  59. Display custom post type posts first, then default posts
  60. Custom Post Type Category Link
  61. Custom Post type category pages template and loop
  62. Custom fields for custom post type
  63. Three Most Recent Posts, One Per Term
  64. Targeting custom post type
  65. Show future events based on custom field AND order by date
  66. Does WP have a global of $id?
  67. WordPress Loop if/else
  68. get_the_title() is returning results from previous loop
  69. Meta Data for Custom Post Type not saving
  70. Using preg_replace to filter custom textarea
  71. Custom Post Loop pulling all custom posts, not just one
  72. Conditional for a Single Post That Belongs to a Category?
  73. Wrapping x posts in html without leaving empty html
  74. WP Query post__in not returning correct results
  75. Custom Post Type single.php template only shows the latest post
  76. Sort posts in loop by the WooCommerce Membership of the author
  77. Check if post with same meta value exists
  78. Filter date from post meta when date is in string format
  79. Including all post id’s of a custom post type into an array
  80. How to include custom post type posts on a page?
  81. 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
  82. Tag page only display 10 posts
  83. Get only used meta_values
  84. If Post Meta Equals Current Title Conditional Advanced Custom Fields
  85. Custom Post Types — $args vs. labels array
  86. Is there a way to exclude posts based on meta_values?
  87. Do posts, pages and / or custom post type objects have unique ID numbers or can there be multiple objects with the same IDs?
  88. How can I group posts by months and years?
  89. Pagination Error : Duplicate argument being outputted
  90. Get an array wich contains the post_name of every post that has the custom post_type “pelicula”
  91. get_post_type is always post
  92. Archieve.php not loading for custom post type
  93. Multiple Custom Post Type queries, how to DRY it up
  94. Custon Content within WordPress Loop
  95. Trying to Create a PHP Variable for post_type that can be referenced Site Wide
  96. Add first letter of titles to array, then compare arrays
  97. Bootstrap accordion looping through posts incorrectly
  98. Main query not querying any posts in custom taxonomy template
  99. Loop increase number
  100. Custom post type showing same Post on all Pages
Categories custom-post-types Tags array, custom-post-types, loop, post-meta
Are mu-plugins plugins still deployed via wordpress.org/plugins?
Display A list of Admins

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