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

Unable to gather Image URL from Custom Post Type’s; Custom Meta Field

If you want the image URL you should use wp_get_attachment_image_url(), not wp_get_attachment_image():

$background_image_id    = get_post_meta(get_the_ID(), 'your_background_image_id', true);
$background_image       = wp_get_attachment_image_url( $background_image_id, 'full' );
$profile_image_id       = get_post_meta(get_the_ID(), 'your_profile_picture_id', true);
$profile_image          = wp_get_attachment_image_url( $profile_image_id, 'full' ); ?>

wp_get_attachment_image() returns a full HTML <img> tag, but background images are just a URL.

Related Posts:

  1. How Can I save multiple records in same meta key?
  2. Custom fields for custom post type
  3. Show posts from WP Custom Post Type selected from a field in a metabox
  4. Querying meta values within an array
  5. Check for custom field value in different post type than current one and do something
  6. Query custom fields with three dates – start and end does not work
  7. meta_query compare >= not working but
  8. Metadata for a taxonomy – is there any WordPress way of doing this?
  9. List all images from a single post meta value
  10. Populate Custom Fields in a Custom Post Type?
  11. Insert Multiple Post with Same Publish Button
  12. WP_Query: include custom post type only with specific meta value
  13. Returning a list of custom post types excluding those without a specific meta_value
  14. Two near-identical custom field types – one works, the other doesn’t . What can cause this?
  15. Meta Key Value in current-user-only loop
  16. How to check if user meta field is empty in conditional else statement
  17. wp_query check if integer exists in custom field’s array
  18. Filtering custom post type on a combination of custom taxonomies and custom fields?
  19. Get posts between custom dates
  20. Give a permalink to Custom Post Types without title
  21. How to implement a Google map store locator
  22. Posting to a Custom Post Type from front end – user generated content
  23. Update Post Meta for a logged in user
  24. Getting meta in editor plugin, and event triggering issue
  25. Orderby CPT custom fields not working
  26. A better way to add a meta box to custom post types
  27. Two Custom Post Types Many to Many Relationship
  28. get_post_meta not working on publishing
  29. Meta Query Not Returning Output Despite Having Matching Values
  30. Meta Query Filtering not working on Custom Meta Box using Radio Buttons
  31. How do I set all of a particular post meta to a value within the custom post type I’m in?
  32. How to use TinyMCE Editor for one of my custom post meta field?
  33. How to Create a WordPress Plugin With Custom Post Type/Custom Field Features?
  34. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  35. Meta Query posts not showing on ending date of custom field
  36. Admin Custom Meta Box – Pull Last 5 Posts from Custom Post Type
  37. How to Output which matched meta_keys were found from custom_type_posts?
  38. Possible to filter custom post type with multiple meta data?
  39. Importing Data from a Non-WordPress database, into WP
  40. custom comments form for custom post type
  41. filter search custom field query
  42. How to let users choose where to search for posts?
  43. Query based on custom fields start and end date
  44. Check if post with same meta value exists
  45. Custom post type’s extra fields – how to handle?
  46. Send a conditional email notification when a custom field value changes in Post Type
  47. Submitting Custom Post Types with custom fields from Front-end form
  48. create custom meta box with default value
  49. ACF in wordpress
  50. delete_post_meta() for whole CPT / multiple posts?
  51. How to get specific post meta by title or id
  52. Getting a custom post’s custom field based on another custom post’s custom field select
  53. WP_Query of custom post type sorted by meta_key has unexpected results
  54. copy images from custom field to another custom field
  55. Custom Query: If One Post Object Field Value Is The Same As Another
  56. How to show custom field on specific custom post type posts only when filled
  57. Custom post type in Custom widget – $listItem
  58. Cannot obtain custom meta information
  59. Problem with adding custom post type meta to header by plugin
  60. How can I output WPAlchemy repeating fields meta values in my page template?
  61. How to call a post’s metadata in shortcode.php?
  62. Generating and downloading files with WP API
  63. WP_Meta_Query object with conditionals
  64. delete duplicate meta_value with same post_id
  65. Search CPT Title AND Meta
  66. updating one custom meta field only
  67. Add a class to post_class if more than one post shares same meta_value_num
  68. Fill custom fields when saving custom post types
  69. Add a meta field to the list of results for a custom post type
  70. Empty meta-box returns publishdate if no value is set?
  71. Writing a custom Glossary plugin
  72. Filter search posts by post meta?
  73. Mandatory field in Custom post
  74. Custom fields for post or terms which don’t update on post update
  75. order the meta query results by 2 custom fields
  76. How to store the third party script with HTML code in the wordpress custom input field?
  77. Custom Post Type meta data getting deleted on bulk editing taxonomies
  78. Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
  79. Using OR relation in meta_query to check for a value before sorting by another
  80. How to upload an image to a custom post type
  81. How to keep custom post type related information
  82. Meta query and compare “!=” not working as expected
  83. Orderby if between two meta fields
  84. How to select meta key in custom database query
  85. Use WP_query to match post types based on custom field values
  86. How can I add a meta[] to my custom post type and search by term with the Rest API?
  87. Creating an archive page or simple template to list all values of a custom field of specific post type listing
  88. Where is get_post_meta value located?
  89. Custom meta fields not showing up in WP_Response Object via custom endpoint
  90. meta query multiple values for the same key
  91. Sort custom post archives by a meta value from a different custom post type?
  92. Show Post columns to specific users on condition
  93. Custom post types – meta_query: search lesson which starts sooner
  94. Error when moving custom post type to bin
  95. How to Disable option of meta field if that option is selected for any other post in custom post type?
  96. Meta_Query refuses to return results
  97. Sort loop by custom field from different post type
  98. Run query on specific admin options page and send results to select field in another function
  99. Meta_query by date for Events archive
  100. Custom post type that lets users create a set of posts?
Categories custom-post-types Tags custom-field, custom-post-types, meta-query, plugin-development, post-meta
hide theme files for admin beneath root
How to check category name available or not

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