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

Delete post meta by serialized meta value

Try below code to delete the post_meta by a specific value of the specialized data:

$args = array(
    'post_type' => 'post',
    'meta_key' => 'any-meta-key',
    'posts_per_page' => -1
 );

$query = new WP_Query( $args );
if($query->have_posts()){
    while($query->have_posts()){
        $query->the_post();
        $get_ID = get_post_meta($post->ID, 'any-meta-key', true);

        // Change the id value that you want to delete 
        if ( !empty($get_ID['id']) && $get_ID['id'] == '1' ) {
            delete_post_meta($post->ID,'any-meta-key',$get_ID);
        }
    }
}

Don’t forget to update the test meta key by your meta key.

Related Posts:

  1. Cleaning up WordPress to improve performance?
  2. List of all theme customizer control types?
  3. Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
  4. the_post_thumbnail() based on the Post ID
  5. Change comments form title on a page by page basis
  6. Setting up the child theme so as to enable right-to-left WordPress?
  7. Why does “get_option” pull in the older value in options.php, rather than the newer value, on submission of a form?
  8. delete an array element when its date expires
  9. How can update custom meta for all posts
  10. How to add 2 posts under another post? Formatting should be intact
  11. How to add default images into theme customizer image control?
  12. Overriding a theme redux file in child theme
  13. How to display custom field on homepage
  14. How to break down importing of feeds
  15. How to Display Image Meta underneath EVERY image in EVERY post
  16. PHP can I add line numbers to file_get_contents()
  17. Use wp_get_recent_posts with search term
  18. Remove query string specific key value
  19. Use WP_Query in shortcode
  20. Get Current User Id Inside a Loop Returns 0 For a Shortcode
  21. Random order of WP_Query results with highest meta value
  22. Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
  23. Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
  24. Converting HTML Template to WordPress Theme
  25. How to check if a meta value has already been assigned to any user?
  26. Retrieve $_POST data submitted from external URL in WordPress(NOT API)
  27. How to prevent WP_Query function from returning all posts when empty?
  28. How to pick the default selected value in wordpress dropdown?
  29. Get users that likes the post
  30. Modify custom field input data before creating a new post
  31. Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
  32. Remove echo from shortcode
  33. Need help enqueueing webfonts
  34. Redirect to another page using contact form 7? [closed]
  35. Is it possible to retrieve all posts with a certain value for metadata?
  36. How to obtain the current website URL in my theme?
  37. Exclude posts with specific metadata from search?
  38. Function Reference Documenting Template Tags for use in Custom Theme Templates?
  39. Create page template via functions.php?
  40. How to create a field in customize and show that in header.php?
  41. WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
  42. change the default order of posts only for specific categories
  43. Custom query vars filters problem with pagination
  44. How do i wrap woocomerce attribute in list?
  45. get_theme_mod outputs number when using WP_Customize_Cropped_Image_Control
  46. How to get post category list as select in front-end?
  47. Order a WP_Query by meta value where the value is an array
  48. Is there a hack for using is_page() within the function.php file?
  49. Unable to Call More than One Meta Box Output
  50. Hide a div when a custom field is empty
  51. Displaying Event within two given time frames
  52. Customize field names in backend profile edit page through function.php [duplicate]
  53. Let current user know pending posts counts using wp_query
  54. How to check post meta isset or not empty during publish/save post?
  55. Output product category link from WP_Query
  56. Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
  57. “pre_get_posts” orderby custom date field in different format?
  58. WP-Bakery – Add custom colors to buttons with template colors
  59. How to exclude meta no index pages from wp_list_pages
  60. Trying to update Woocommerce meta values
  61. How to add and subtract user meta values after post meta update
  62. WP query posts BUT show the most recent and one per author
  63. Ajax filter with loadmore button
  64. update_user_meta as multiple value but with same meta key
  65. posts_per_page displays only 2 posts instead of 4 posts
  66. Modify post image in full size
  67. WP_Query To Display Product Of Brand On Taxonomy Page
  68. Remove node from multisites?
  69. Automatically refresh page if widget is added to page?
  70. Stored meta from attachment, video length?
  71. My query keeps looping infinitely ! how to stop it?
  72. Efficient way of querying for a “fallback” post?
  73. Where can I find the declaration of `$_wp_theme_features`?
  74. How do I routinely extract the thumbnail of the most recent post?
  75. Display Year and Month from custom field + Age Calculator
  76. insert thumbnail image from php script
  77. A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
  78. Weird Behaviour: Not all WordPress Posts appearing
  79. My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
  80. Use custom get results query to show posts WordPress
  81. Postmeta not saving
  82. Check if values exists DB
  83. How to get category pages to look like a certain archive page?
  84. get_post_meta no longer working
  85. WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
  86. How can I clear the theme mod settings?
  87. Display a list of users with avatar filterable with alphabets
  88. Select area and checkbox data is not saving?
  89. How to modify this function to exclude also the post belonging to a specific category?
  90. How to display the date under the post title?
  91. WP Custom tables query
  92. Add multiple HTML attributes to an Elementor button
  93. How do I get a function to work in single.php
  94. a problem in class in class-wp-hook.php
  95. /page/2/ redirect to 404
  96. Add adjacent post function inside custom recent post function
  97. Woocomerce custom add to cart button edit functionality [closed]
  98. How to change product title color in shop page if product has specific product tag (Woocommerce)?
  99. Restricting page by user role
  100. Developing a “fallback” for empty wp_query results based on post dates
Categories PHP Tags customization, functions, php, post-meta, wp-query
Better search on WordPress.org Plugins?
Count how many posts have a specified tag AND 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