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

Hide a div when a custom field is empty

I think what you are looking for is something like:

 <?php $post = get_post_meta($post->ID, '_cmb_fe_wysiwyg', true) ; if (!empty($post)) { ?>
        <div id="ingredientsNeeded">
              <h3>Ingredients</h3>
              <?php echo wpautop( get_post_meta( get_the_ID(), $post . '_cmb_fe_wysiwyg', true ) );?>
        </div>
  <?php } ?>

This will check that the value is empty and if so will hide the div

Related Posts:

  1. How can update custom meta for all posts
  2. How to update custom fields using the wp_insert_post() function?
  3. How to automatically apply woocommerce product title to all product images alt tags?
  4. How to display multiple Post meta_key/meta_values by SQL query
  5. the_post_thumbnail() based on the Post ID
  6. How to use multiple query with same meta key
  7. Add custom field to attachments in a specific category
  8. Use ajax to update_post_meta
  9. how to increase custom post value by one most efficiently?
  10. How to Display Image Meta underneath EVERY image in EVERY post
  11. How can I create a list of page titles from custom meta values?
  12. Passing the custom field values in the wp_get_current_user array function
  13. Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
  14. How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
  15. get_post_meta not working on publishing
  16. Firing schema via code in functions.php doesn’t work
  17. 3 Slashes appear after Apostrophe in custom fields after updating product-site
  18. Trying to retrieve post meta
  19. Which PHP page is the Default Posts Page
  20. Is it possible to retrieve all posts with a certain value for metadata?
  21. Non-Closing PHP Query in WordPress Loop
  22. How to check if a PHP string is different than meta field?
  23. Can’t save php string to a custom field
  24. Why does this update_post_meta function not delete the custom field itself?
  25. How to show/hide php table rows based on the content of custom fields
  26. how to get serialized post meta
  27. Custom meta box values are not getting saved for my custom post type
  28. Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
  29. WordPress loop by meta key that is an array? and how loop multiple arrays
  30. WP All Import / Update stock quantity from multiple XML files
  31. How to store multiple custom meta box
  32. Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
  33. How to add data to a custom field at the wp_users table?
  34. Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
  35. Order a WP_Query by meta value where the value is an array
  36. Add a custom class to the body tag using custom fields
  37. Define category ID using get_post_meta
  38. Unable to Call More than One Meta Box Output
  39. Conditional On custom field plugin metabox
  40. WordPress stripping out custom field tags
  41. How to check post meta isset or not empty during publish/save post?
  42. Delete images from media library when user deletes an image from ACF Gallery
  43. Updating Metadata with Shortcode
  44. Order category posts by last word of custom field
  45. Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
  46. Products listing check if meta checkbox is checked
  47. Trying to update Woocommerce meta values
  48. How to add and subtract user meta values after post meta update
  49. Is it possible to update the dataset using update_post_meta
  50. How to update custom fields when post is published?
  51. Block error message in foreach loop when looping through ACF field
  52. Hide a div if the fiels is empty
  53. Delete post meta by serialized meta value
  54. How do I get the value of a current user’s custom field?
  55. WP post meta – for loop inside for loop
  56. Store custom field’s multiple values in one user meta key
  57. Get field in readable word
  58. When working with a post, almost all wp_postmeta are deleted
  59. Updating Lat and Lng of posts automatically gives sporadic results
  60. Postmeta not saving
  61. If custom field doesn’t exist, or exists and it’s true show title?
  62. get_post_meta no longer working
  63. Display custom meta box in my template file
  64. ACF Date fileds to Age Convert [closed]
  65. Metadata on the WP_Post object
  66. How to display the date under the post title?
  67. Appending an ACF custom field to the page title
  68. How do I get a function to work in single.php
  69. How to pass value to add_filter wpcf7_form_tag from another function?
  70. Custom Admin Menu Report for Specific User ID
  71. ACF number less than comparison not working
  72. Exclude function for custom pages, exclude custom ACF fields
  73. How to hide the author box of a specific user?
  74. Else/If Statement to Display Photo Descriptions
  75. Add date before entry title in Twenty Twelve
  76. Count foreach and display in menu php
  77. Removing “Powered by” footer using child theme PHP [closed]
  78. This function is deprecated; use mysql_real_escape_string() instead
  79. How do i wrap woocomerce attribute in list?
  80. Removing files programmatically
  81. Missing a text-domain esc_attr_e
  82. get_theme_mod outputs number when using WP_Customize_Cropped_Image_Control
  83. Overide Variable in Child Theme
  84. How to remove the space before the ellipsis in excerpt?
  85. Update post meta – Custom field does not match meta-key
  86. child parent styles enqueue order
  87. Output custom text field as unordered list
  88. Conditional featured image with youtube thumbnail
  89. Add URL parameter to all internal links using a specific theme
  90. How to add aria role and schema markup to custom walker container
  91. Adding an interior ‘hero’ area with some added php title customization
  92. get_page_templates only return templates with “home” in the filename
  93. Warning: call_user_func() expects parameter 1 to be a valid callback, function
  94. How can I use custom menus with a Bootstrap WordPress theme?
  95. Custom posts password protect
  96. Change MySQL PDO connection to a WPDB connection
  97. Call to undefined function error in plugin
  98. How to get post category list as select in front-end?
  99. How do I correct the code in php? [closed]
  100. `update_post_meta` not working anymore
Categories PHP Tags custom-field, functions, php, post-meta
Filter to hook into menu items and add a custom attribute
How do I reset a rewrite?

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