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

Image not showing using a custom function and get_post_meta

UPDATE Ok, thanks to all for helping me out and pointing me in the right direction. I do have some code clean up to do and a possible all out change in code but I’ll use this for now.

I got it to work with the following code.

//El display image
function el_display(){
    global $post;
    $eldisplay = get_post_meta($post->ID, '_cmb_el_theme', true);
    $elcustomdisplay = get_post_meta($post->ID, '_cmb_custom_image', true);

        if(!empty($eldisplay)){
            echo '<img src="' . $eldisplay . '" />';
                }elseif(!empty($elcustomdisplay) && isset($elcustomdisplay)){
                echo '<img src="' . $elcustomdisplay . '" />';
            }else{
                echo '<img src="' . EL_IMG . 'mobile-development.jpg' . '" />';
            }
}

Thanks again!

Related Posts:

  1. Upload multiple images in a custom metabox
  2. Adding upload button in metabox
  3. Regenerate missing _wp_attachment_metadata
  4. Image display from custom field
  5. Include captions
  6. Retrieving an alt tag from a custom field
  7. Get thumbnail url of custom meta image?
  8. Dynamic tagged image galleries
  9. Generate images to be associated for tag and category?
  10. Add custom metabox to media library images
  11. Display an icon with get_post_meta?
  12. Remove “%” from strings in serialized arrays in wp_postmeta
  13. WordPress Featured Image meta box not showing
  14. Metabox image upload value
  15. How to join Caption AND Description Meta Fields as one combined-caption in Image Block
  16. How to Display Image Caption but Not Alt Text
  17. featured image in custom poste type (backend)
  18. get_post_meta returning broken path in image src
  19. problem with updating metabox of upload image
  20. Adding Image Description below Images Inserted into Posts
  21. Upload button in metabox not working
  22. get_post_custom: get image URL instead of image ID
  23. Adding different classes to different images depending on size for fine control of image layout in posts
  24. How can I get or the intermediate size of an image with wp_get_attachment_image_src without using post meta?
  25. show hide image script after 4 seconds [closed]
  26. Restricting users to view only media library items they have uploaded?
  27. How do I disable responsive images in WP 4.4?
  28. Filter to remove image dimension attributes?
  29. How to get a list of all the possible thumbnail sizes set within a theme
  30. How do I get the avatar URL instead of an HTML IMG tag when using get_avatar?
  31. Image Upload from URL
  32. Programmatically adding images to media library
  33. How do I delete all UNUSED images from my uploads directory?
  34. Set default image sizes in WordPress to hard crop
  35. Passing error/warning messages from a meta box to “admin_notices”
  36. Is it possible set a featured image with external image URL
  37. get attachment title based on attachment id
  38. Add “upload media” button in meta box field
  39. Stop wordpress from hardcoding img width and height attributes
  40. Handle issues with change of image scaling (rounding) in 4.1 (WP Ticket #18532)
  41. Programmatically get images by URL and save in uploads folder
  42. Prevent WordPress from generating medium_large 768px size of image uploads?
  43. remove or update add_image_size
  44. Get Image Description
  45. How to extend the gallery block in Gutenberg?
  46. Image quality based on image size
  47. Function to get URL of original uploaded image – full size
  48. how to get original image using wp_get_attachment_image_src
  49. What is a good alternative to using $content_width for image optimization?
  50. get the attachement url for the medium sized image
  51. Can I attach image to post without adding it to post?
  52. Automatically replace original uploaded image with large image size
  53. WordPress crop tool greyed out
  54. How to scale up featured post thumbnail?
  55. Upload images to remote server
  56. Custom image size / thumbnail – Crop to aspect ratio even when source image is smaller than set dimensions
  57. Each custom image size in custom upload directory?
  58. Getting Images from theme’s directory in pages
  59. Set default image link target in Gutenberg image block
  60. Add an alignment option for images
  61. What is the index [0] for on post meta fields?
  62. How to delete resized (cropped) image uploads and prevent future resizing?
  63. How to automatically add rounded corners to thumbnails?
  64. WordPress adding scaled images that don’t exist (1536×1536 and 2048×2048)
  65. Download an image from a webpage to the default uploads folder
  66. Add image size where largest possible proportional size is generated
  67. WP 4.4. responsive images browser choosing the “wrong” one
  68. After Moving a Site to Another Domain, All Images Are Lost
  69. Prevent WordPress from adding image’ title automatically
  70. Overide Gallery Default Link to Settings
  71. Retrieve featured image
  72. How to change image type for specific size?
  73. Add new image size to media uploader so users can insert into post?
  74. How to insert pictures without hard coded dimensions?
  75. Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
  76. How to modify image editor dialog options on WordPress?
  77. Why WordPress automatic cropping all my images?
  78. Allow contributor role to upload images and not edit already published articles
  79. What’s the proper way to find and remove duplicate images from posts and the media library?
  80. Remove images (files) that were generated when using add_image_size()
  81. post formats – how to switch meta boxes when changing format?
  82. get_post_gallery with Gutenberg
  83. Is there a hook which fires after all thumbnails are generated?
  84. Auto Add Image Title,Caption,Alt Text,Description while uploading Images in WordPress
  85. Is there a simple way to just insert a link to an image (without inserting an image)?
  86. Watermarking Images with WordPress with WP_Image_Editor
  87. How to avoid WordPress stripping EXIF metadata when resizing images?
  88. is it possible to replace the use of gd_lib with imagick or ImageMagick?
  89. How to have different captions for same image, for galleries?
  90. Get attachment/image info in JS
  91. How to reference a theme image in a stylesheet?
  92. wp_get_attachment_image_src and server path
  93. Limit image resolution on upload
  94. How can I retrieve multiple get_post_meta values efficiently?
  95. How to display a page’s featured image?
  96. Separate Media Library for each user
  97. Featured image shortcode
  98. get_post_gallery_images returns thumbs . I want full size
  99. Setting JPEG compression for custom image sizes doesn’t work in specific cases
  100. Maintaining image color and quality when uploading using custom sizes
Categories images Tags images, metabox, post-meta
I can’t connect my custom jquery to wp admin
Placing a featured image into header

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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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