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 All Custom Post Fields and Values, Unless Empty

This can easily be done with default PHP functions.

// Loop through all fields, grab the content and assign it to a new array
foreach ( get_post_custom() as $custom )
    $new_custom[] = array_shift( $custom );

// Get rid of empty fields
$new_custom = array_filter( $new_custom );

Related Posts:

  1. WordPress Action Hooks and Post ID?
  2. get_post_meta of multiple posts?
  3. How do I retrieve the slug of the current page?
  4. Most efficient way to get posts with postmeta
  5. Get posts by meta value
  6. what is the correct way to compare dates in a WP query_posts meta_query
  7. Explanation of update_post_(meta/term)_cache
  8. How to extract data from a post meta serialized array?
  9. Can I exclude a post by meta key using pre_get_posts function?
  10. Advanced search form with filters for custom taxonomies and custom fields
  11. How to update custom fields using the wp_insert_post() function?
  12. Can wp_query return posts meta in a single request?
  13. How to save an array with one metakey in postmeta?
  14. WordPress is stripping escape backslashes from JSON strings in post_meta
  15. How can I get the post ID from a WP_Query loop?
  16. Custom post meta field effect on the performance on the post
  17. Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does
  18. How to get custom post meta using REST API
  19. Difference between meta keys with _ and without _ [duplicate]
  20. Orderby meta_value only returns posts that have existing meta_key
  21. What is the index [0] for on post meta fields?
  22. What is “meta_input” parameter in wp_insert_post() used for?
  23. How to update_post_meta value as array
  24. Adding meta tag without plugin
  25. How to enable revisions for post meta data?
  26. What’s the point of get_post_meta’s $single param?
  27. The “_encloseme” Meta-Key Conundrum
  28. What is the different between an attachment in wp_posts and an attachment in wp_postmeta?
  29. Best way to programmatically remove a category/term from a post
  30. How to edit a post meta data in a Gutenberg Block?
  31. Sanitizing integer input for update_post_meta
  32. post formats – how to switch meta boxes when changing format?
  33. Using get_post_meta with new_to_publish
  34. Execute action after post is saved with all related post_meta records (data)
  35. Lack of composite indexes for meta tables
  36. Custom field values deleted when trashing custom post type
  37. How to get all custom fields of any post type
  38. Get a single post by a unique meta value
  39. Admin Area Custom Type Search By Meta Fields Without Title & Content
  40. if get_post_meta is empty do something
  41. How we get_post_meta without post id
  42. How get post id from meta value
  43. What is the code to get the download link for a product in WooCommerce?
  44. Safe to delete blank postmeta?
  45. Custom field metabox not showing in back-end
  46. How do I Paginate Search Results for Custom Post Types?
  47. So much data in postmeta
  48. advanced custom fields update_field for field type: Taxonomy
  49. update_post_meta not saving when value is zero
  50. Can I count the number of users matching a value in a multiple value key?
  51. Content hooks vs User hooks
  52. Meta compare with date (stored as string) not working
  53. Getting attachments by meta value
  54. When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?
  55. How to hide meta box values from custom fields list?
  56. Auto sort the wp-admin post list by a meta key
  57. Trying to get custom post meta through Jetpack JSON API [closed]
  58. How to update/insert custom field(post meta) data with wordpress REST API?
  59. get_post_meta() unserialize issue – returns boolean(false)
  60. What is the advantage of the wp_options design pattern?
  61. meta_query where value is equal to given value
  62. Restrict post edit/delete based on user ID and custom field
  63. Storing meta fields multiple times OR once with multi dimensional array?
  64. Update all posts automatically when using post_meta
  65. Allow user to create instances of custom field
  66. get_post_meta returning empty string when data shows in the database
  67. publish_post action hook doesn’t give post_meta_data
  68. Remove WordPress.org Meta link
  69. Remove post meta keys
  70. How to access the post meta of a post that has just been published?
  71. Why time functions show invalid time zone when using ‘c’ time format?
  72. display specific custom fields
  73. Save metabox with multiple checkbox array
  74. Why is get_post_meta returning an array when I specify it as single?
  75. How Can I save multiple records in same meta key?
  76. Is there a hook / action that is triggered when adding or removing a post thumbnail?
  77. How to update/delete array in post meta value?
  78. How to get all term meta for a taxonomy – getting term_meta for taxonomy
  79. Adding an assisting editor box to Post page
  80. Meta keywords and descriptions plugin for manually editing meta for each page/post
  81. How to display multiple Post meta_key/meta_values by SQL query
  82. Add options to featured image
  83. passing argument to get_template_part() or a better way to code
  84. Is it possible to store arrays in a custom field?
  85. Get updated meta data after save_post hook
  86. Detect meta value changes when post is updated (post_updated)
  87. Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post
  88. How to use multiple query with same meta key
  89. Save HTML formatted data to post meta using add_post_meta()
  90. delete unused postmeta
  91. Search everything (posts, pages, tags, cpt, meta)
  92. importing data from non-wordpress mysql db
  93. Should I sanitize custom post meta if it is going to be escaped later?
  94. Add post meta based on another post meta value before publish post
  95. Custom query with category exclusion and post-meta “whitelist”
  96. How do I retrieve multi-dimensional arrays from the wp_postmeta table, & display on a website?
  97. Front-end update_post_meta snippet displays white screen?
  98. Query between two meta values?
  99. Save both current and new version of post meta
  100. Get Advanced Custom Fields values before saving [closed]
Categories post-meta Tags custom-field, post-meta
WordPress folder ownership issues
Use child theme on certain pages and not others?

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