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

get_post_meta printing empty fields, but it shouldn’t be

The get_post_meta function returns an empty string if the key has not yet been set. That means the unused fields are going to result in $link having a value of ”, NOT a value of NULL.

The isset function returns TRUE if the variable exists and has value other than NULL. As $link is not NULL (it’s ”), isset will return TRUE and your code will run.

Perhaps you should use empty instead of isset, although for some reason, I typically use the following:

if (isset($link) && $link != '')

Related Posts:

  1. How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()? [closed]
  2. Get ID of a page containing secondary loop in content
  3. How to add “time” data this?
  4. Next and Previous loop
  5. How to hook into container
  6. Output meta into arrays
  7. value of metadata is null wrong use of if statement
  8. Sending mail not working correctly
  9. using update_user_meta to rank users
  10. Check value of post meta within IF statement
  11. Best way to check if a post with specific meta exists
  12. WP update_post_meta link loop
  13. Humanmade | Custom meta box class: How to display a repeatable meta box group?
  14. Display articles related to a custom field on a page
  15. Redirect loop when trying to login to /wp-admin/ [duplicate]
  16. How can I custom order the results from wp_list_categories?
  17. When and Why is is_singular(‘my_cpt’) true while in_the_loop() is false?
  18. Display all authors and their only one latest post
  19. Remove comma from last item output from loop
  20. Getting page ID inside loop
  21. Page template not displaying
  22. How to show just private posts in loop
  23. How to paginate this custom loop? [duplicate]
  24. Can I use both a custom excerpt and a trimmed excerpt?
  25. Select data from database and list it in Loop (WordPress)
  26. How to get_template_part using AJAX?
  27. wp alchemy multiple image uploader output images to template
  28. Running a loop with a custom query string on a custom page template
  29. I’ve been out of the loop since 2.8. What did I miss?
  30. Loop first six posts in carousel, next eight in grid
  31. Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
  32. Infinite blog loop
  33. One custom loop with condition to check child posts
  34. Loop get_theme_mod
  35. Move sticky posts down in main loop
  36. Why only one post (and no pagination) on this variation of the loop?
  37. Loop in Related Posts WordPress
  38. Template structure
  39. The Loop – mixed ASC and DESC order
  40. Filter the_posts doesn’t work on search page
  41. Custom Loop Using Shortcode in Custom Page Template
  42. Listing subpages title and content and styling the first iteration differently
  43. Latest Post Styled Different Than other Posts
  44. ACF custom field in [closed]
  45. Split wordpress loop to multiple layouts
  46. WordPress: Loop Help
  47. Woocommerce: How to display product price [closed]
  48. Update status of all posts in a category
  49. Enabling users to control custom loop’s query
  50. Loop counter style
  51. Can I add generic numbering HTML classes to items as a loop runs?
  52. Add “showing posts x to x of y” in custom post type paginated loop
  53. Custom Post Type on Homepage – Studiopress Genesis Framework
  54. New loop vs widget
  55. Display a single category in blog section
  56. Query Nopaging action not having effect
  57. Yoast taking over my WordPress title tag [closed]
  58. Pagination broken after using 2 loops to show content
  59. Getting page slug
  60. How to get pagination to work with 2 wordpress loops
  61. Exclude page from loop results
  62. How is WordPress changing the content markup?
  63. Inserting CPT and static content at every X post, is this possible?
  64. Get most recent post for every term in a given taxonomy type
  65. Filtering by multiple conditions in the loop
  66. loop through posts and display inserted media and post title as a link
  67. Custom Blog Loop on Home Page
  68. Exceprt not displaying
  69. Add File Attachment Name and URL into Javascript
  70. Open Graph in Index Loop
  71. Using is_page_template inside loop
  72. How to add custom checkboxes from loop to WooCommerce product variation options?
  73. Archive: Lists itself
  74. Please tell how to stop the category from showing up on posts
  75. How to show the last article in a different way in my blog?
  76. Can’t limit posts_per_page in loop
  77. Slug is changing when I use WP_Query in a metabox of a post
  78. How to fix pagination for custom loops?
  79. Check to see if a field is within an array in twig
  80. Custom loop not working in singular.php, working in other pages
  81. Strange problem with wp_get_attachment_image_src database (db) query count
  82. Archive sorted by month – separate
  83. One page loop issue with posts
  84. Can’t print out returned value
  85. change the_content images for different sizes (Desktop, tablet, mobile)?
  86. Get query result before posts are displayed?
  87. WordPress Group By Problem
  88. Home page loop with pagination problem
  89. why get_post_meta is returning 0?
  90. WooCommerce custom loop pagination on front page
  91. Eliminate duplicates in a foreach loop [closed]
  92. Tag custom loop show posts
  93. get_page() unlike Loop returns the post content without html tags. How can I fix this?
  94. Problem with ms-thumb-frame-selected class in Master Slider
  95. I want the first post on my home page to be lengthier than the rest (example included)
  96. Loop with Custom Post Type Taxonomies and Interstitial Code
  97. Question about custom plugin
  98. loop mix my child-category and parent-category
  99. How can you make it so the comment box shows on some pages or posts but not all?
  100. Use Base-URL with Query-Loop
Categories loop Tags loop, post-meta
All pages load the home page if pretty permalinks are used
recent comments filter by author, page, category

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