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. Function to return true if current page has child pages
  2. Cleaning up WordPress to improve performance?
  3. List of all theme customizer control types?
  4. Build a content and excerpt grid loop with paging and options for # of posts
  5. How to preserve PHP modifications while upgrading WordPress?
  6. Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
  7. the_post_thumbnail() based on the Post ID
  8. Change comments form title on a page by page basis
  9. Setting up the child theme so as to enable right-to-left WordPress?
  10. Why does “get_option” pull in the older value in options.php, rather than the newer value, on submission of a form?
  11. delete an array element when its date expires
  12. How can update custom meta for all posts
  13. How to add 2 posts under another post? Formatting should be intact
  14. How to add default images into theme customizer image control?
  15. Overriding a theme redux file in child theme
  16. How to display custom field on homepage
  17. How to break down importing of feeds
  18. How to Display Image Meta underneath EVERY image in EVERY post
  19. PHP can I add line numbers to file_get_contents()
  20. Use wp_get_recent_posts with search term
  21. Remove query string specific key value
  22. Redirect to another page using contact form 7? [closed]
  23. Security for data obtained from the database
  24. Is it possible to retrieve all posts with a certain value for metadata?
  25. How to obtain the current website URL in my theme?
  26. What exactly do this function declared into functions.php file of a WP theme?
  27. Exclude posts with specific metadata from search?
  28. Function Reference Documenting Template Tags for use in Custom Theme Templates?
  29. Create page template via functions.php?
  30. How to create a field in customize and show that in header.php?
  31. WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
  32. change the default order of posts only for specific categories
  33. Post not populating for custom post type based on category selection
  34. List post by title length
  35. Custom query vars filters problem with pagination
  36. How do i wrap woocomerce attribute in list?
  37. get_theme_mod outputs number when using WP_Customize_Cropped_Image_Control
  38. How to get post category list as select in front-end?
  39. Order a WP_Query by meta value where the value is an array
  40. Is there a hack for using is_page() within the function.php file?
  41. Unable to Call More than One Meta Box Output
  42. Hide a div when a custom field is empty
  43. Displaying Event within two given time frames
  44. Customize field names in backend profile edit page through function.php [duplicate]
  45. WP insert post Redirect after function has executed
  46. Let current user know pending posts counts using wp_query
  47. How to check post meta isset or not empty during publish/save post?
  48. Output product category link from WP_Query
  49. Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
  50. “pre_get_posts” orderby custom date field in different format?
  51. WP-Bakery – Add custom colors to buttons with template colors
  52. How to exclude meta no index pages from wp_list_pages
  53. Trying to update Woocommerce meta values
  54. How to add and subtract user meta values after post meta update
  55. WP query posts BUT show the most recent and one per author
  56. Ajax filter with loadmore button
  57. update_user_meta as multiple value but with same meta key
  58. posts_per_page displays only 2 posts instead of 4 posts
  59. Having trouble creating two shortcodes, one for logged in user and one for visitors
  60. Modify post image in full size
  61. WP_Query To Display Product Of Brand On Taxonomy Page
  62. Custom Post type Ajax search results
  63. Remove node from multisites?
  64. Automatically refresh page if widget is added to page?
  65. Stored meta from attachment, video length?
  66. My query keeps looping infinitely ! how to stop it?
  67. Efficient way of querying for a “fallback” post?
  68. How can I display a query in a page?
  69. Where can I find the declaration of `$_wp_theme_features`?
  70. How do I routinely extract the thumbnail of the most recent post?
  71. Display Year and Month from custom field + Age Calculator
  72. insert thumbnail image from php script
  73. A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
  74. Weird Behaviour: Not all WordPress Posts appearing
  75. My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
  76. Use custom get results query to show posts WordPress
  77. List sibling pages widget, exclude current page
  78. Postmeta not saving
  79. Check if values exists DB
  80. How to get category pages to look like a certain archive page?
  81. get_post_meta no longer working
  82. WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
  83. How to add button to top of theme customizer?
  84. How can I clear the theme mod settings?
  85. Display a list of users with avatar filterable with alphabets
  86. Select area and checkbox data is not saving?
  87. How to modify this function to exclude also the post belonging to a specific category?
  88. How to display the date under the post title?
  89. WP Custom tables query
  90. Add multiple HTML attributes to an Elementor button
  91. How do I get a function to work in single.php
  92. a problem in class in class-wp-hook.php
  93. /page/2/ redirect to 404
  94. Add adjacent post function inside custom recent post function
  95. wp_logout action hook is not firing
  96. Woocomerce custom add to cart button edit functionality [closed]
  97. How to change product title color in shop page if product has specific product tag (Woocommerce)?
  98. How to capture number input from wordpress form into acf field in 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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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