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 an icon with get_post_meta?

The syntax for get_post_meta that you are using in incorrect. It is documented here.

You need to pass a string for the second parameter. So, for example, use

$icon = get_post_meta( $post->ID, 'apaitei_logariasmo_facebook', true );

Instead of

$icon = get_post_meta( $post->ID, apaitei_logariasmo_facebook, true );

In addition, string literals must be between the quotes in PHP.

if( $icon == esc_attr( 'Ναι' ) ) :

So, the solution is:

<?php
$icon = get_post_meta( $post->ID, 'apaitei_logariasmo_facebook', true );
if( $icon == esc_attr( 'Ναι' ) ) : ?>
<span class="facebook-badge"></span>
<?php endif; ?>

Related Posts:

  1. Regenerate missing _wp_attachment_metadata
  2. Retrieving an alt tag from a custom field
  3. Get thumbnail url of custom meta image?
  4. Dynamic tagged image galleries
  5. Generate images to be associated for tag and category?
  6. Remove “%” from strings in serialized arrays in wp_postmeta
  7. Can wp_get_image_editor convert to icon?
  8. Image not showing using a custom function and get_post_meta
  9. How to join Caption AND Description Meta Fields as one combined-caption in Image Block
  10. Hover a css icon width other color inside wp_get_attachment_image
  11. Widget Style – Icon Type
  12. How to Display Image Caption but Not Alt Text
  13. get_post_meta returning broken path in image src
  14. Adding Image Description below Images Inserted into Posts
  15. get_post_custom: get image URL instead of image ID
  16. remove or update add_image_size
  17. get the attachement url for the medium sized image
  18. Is there a simple way to just insert a link to an image (without inserting an image)?
  19. Watermarking Images with WordPress with WP_Image_Editor
  20. Auto-modifying original [full size] images
  21. Get attachment ID of author_meta image – Attachment Metadata
  22. Black and White thumbnails
  23. Crop image to horizontal or vertical by code based on image size
  24. Alter image output in content
  25. How can I remove the image attachment ALT field?
  26. Open the attachment details modal
  27. Download button for Featured Image in every post – automatically
  28. Change html structure of all img tags in WordPress
  29. Get a list of all image sizes that match aspect ratio of original one
  30. Randomly add a ‘ul’ list of images
  31. How to Display Featured Image Title and ALT Attribute
  32. Thumbnails are bigger in size than the original image
  33. The the post id from image id
  34. Add attribute to caption shortcode from custom attachment field
  35. Get an image’s alt text in a shortcode using the image URL
  36. Add Small Image Size to Media Settings
  37. Image resize depending on orientation?
  38. Character Limit w/ Excerpt removes Images Why?
  39. Featured images not displaying at full resolution
  40. Check if the image exists in WordPress media library
  41. Faster way to put images into a blog post by using Add Media dialog
  42. WordPress adds extra width to post images container boxes
  43. Retrieve an array of image URLs that belong to a gallery
  44. Help With Custom Image and Text Widget
  45. Images uploaded to the media library has strange colors. However, in the edit screen the color is ok
  46. Upload image without media-upload [duplicate]
  47. Tinymce and uploading local pictures
  48. Time Based change of image
  49. WordPress shows my picture in admin bar
  50. Using Jetpack carousel w/o creating a gallery [closed]
  51. WordPress Facebook Open Graph plugin not working for 1 specific image [closed]
  52. Custom responsive ‘featured image’ sizes
  53. removing the featured image from the post
  54. Dynamic image crop in WP 3.0+?
  55. What can i do add title to ‘large’ image?
  56. WordPress cutting images size
  57. How to set minimum required size for featured image?
  58. Whats causing image quality to be degraded?
  59. Exclude image url from search query
  60. Inserting image into post with different image size
  61. WordPress Resize Image and show as thumb in post
  62. Resize uploaded images [duplicate]
  63. Image “description” and SEO within WP
  64. Indicate image sizes for upload by post type
  65. Why can’t I gain access to my homepage images?
  66. Family collaboration to identify ancestors on pictures
  67. How to change Gallery image url in product page ? In function.php?
  68. Display image of child element in wordpress
  69. How do you obtain a list of all image file names on a wordpress website for replacement?
  70. Form File Upload Field generates multiple copies of Image Files (different sizes): Is this a WP feature or is this being done by the Plugin
  71. Responsive header image
  72. Text Wrapping in Editor not Matching Website View
  73. Duplicate images on upload
  74. Broken images on iphone
  75. Redirect when user clicks on an image
  76. JPG Image extension not inserting into Custom table of wp
  77. wp_get_attachment_image_attributes not working
  78. Responsive images with srcset
  79. Using WP 4.9.6 and big trouble showing images
  80. How to link to img src using HTML email template in WordPress
  81. How to add an image below the header on homepage
  82. List sub pages with custom field content converting image ID to URL
  83. Does the title and description attribute of images ever get shown?
  84. Automatically set full size for all my images in all my post and page?
  85. SVG files and wordpress
  86. Different image margins on different pages CSS [closed]
  87. Small image resizing for big! Alternative to timthumb
  88. Show custom image size smaller in editor
  89. add titles to images in ad media in pages and posts
  90. Setting name of attachment URL
  91. Show title when inserting single images
  92. Editing Featured Image Display When Creating Post
  93. How can I make image linking to attachment page (rather than a direct link)?
  94. wordpress is generating too many Image Sizes
  95. Best Photoshop-WordPress workflow for editing images without re-upload [closed]
  96. Uploaded Media Images on Site
  97. Create decorative image border with CSS? [closed]
  98. How to have the frontend show the appropriate image size?
  99. Copy Content with Images to Other Site
  100. Why are PDF thumbnails over-saturated?
Categories images Tags icon, images, post-meta
How to over-ride a file in a plugin? [closed]
disbale default widgets on theme activation

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