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

WordPress delete mysql rows with string

Look at the documentation, $wpdb->delete() takes at least two parameters, the table name and the Where-conditions as an array(). LIKE isn’t supported for delete imho, so you’ll need to use ->query

global $wpdb;
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE '_cb_%'" );
$wpdb->query( "DELETE FROM $wpdb->posts WHERE post_type LIKE 'webcam'" );

I assume the double closing parentheses and missing quotes were just from copy pasting?

Related Posts:

  1. How can I free up the memory used by update_post_meta?
  2. Insert, update or remove data from database (usermeta)
  3. WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
  4. Objective Best Practices for Plugin Development? [closed]
  5. Should I use wpdb prepare?
  6. Post meta vs separate database tables
  7. How do i best handle custom plugin page actions?
  8. How to create an API for my plugin?
  9. Is it ever okay to include inline CSS in plugins?
  10. Plugins in symlinked directories?
  11. In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
  12. Plugin Form Submission Best Practice
  13. Best way to abort plugin in case of insufficient PHP version?
  14. How can I configure Docker for developing and deploying a custom theme?
  15. What do you think about custom designed plugin/theme options UIs?
  16. No Error Log File, no debug info
  17. Where to put third party PHP library?
  18. Is the new WordPress 3.1 admin bar pluggable and how can I extend it?
  19. How to use PanelColorSettings in custom Gutenberg block?
  20. Getting a peer review for my new plugin?
  21. Optimize shortcode callbacks
  22. How to integrate a PHP webmail script into the backend of WordPress?
  23. Using filters and actions for plugin API?
  24. Is There A Hook To Process The Content Of The Text Widget?
  25. How to Change the Entire WordPress Admin panel Look and Feel?
  26. Getting wrong relationship value in $args in wp_Query?
  27. Does using set_transient() function can lead to MySQL problems?
  28. How to log plugin errors to plugin error_log file
  29. Which to use to execute code during the saving of a plugin settings page?
  30. Allowing for multiple template views on the Gallery Settings page when using the Visual Editor
  31. Using Primary Color in Plugin Block
  32. Save metabox with multiple checkbox array
  33. How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?
  34. How is the data stored in the database?
  35. When is it appropriate to put functions on page template vs. functions.php?
  36. Custom theme sufficient or custom plugin neccessary for this feature set?
  37. When to check if a function exists
  38. How to enable users to down-vote in this simple voting counter (that uses the post meta)?
  39. How to create custom home page via plugin?
  40. Adding callback function for wp_ajax_ has no effect
  41. Sessions not creating correctly in custom function
  42. Featured Image not showing in admin
  43. How to use wp_set_password in a plugin?
  44. Updating post meta for custom post types
  45. How Can I setup WP CLI on Windows development machine running AMPPS?
  46. WP_LOCALIZE_SCRIPT doesn’t work
  47. Nuance in adding CPT and TAX to a submenu
  48. Passing array of strings to a SQL statement in a WordPress plugin
  49. Can I differentiate between “Delete Post Permanently” and “Empty Trash” and do something for each accordingly?
  50. Is there a way to list tags order by post_meta field
  51. Activation hook not creating table
  52. Is the usage of ON DELETE CASCADE wrong or not allowed on wordpress?
  53. Delete a specific item menu when I deactivate my plugin
  54. How to edit mySQL wp_posts table from plugin php?
  55. Are we allowed to use the Allman (BSD) indent style when coding WordPress plugins and themes?
  56. Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?
  57. Plugin development: get_post_meta is not working [closed]
  58. Ordering posts by metadata
  59. $wpdb -> Batch insert from XML File?
  60. Get the password key when using the wp_new_user_notification_email filter
  61. query users by role
  62. Order properties should not be accessed directly
  63. Act on user meta updated, but only once
  64. How to deal with equal & similar arguments for a function?
  65. Executing a function upon webhook calling wordpress
  66. How to check if Woocommerce Order number equals to post ID?
  67. Customizer: widget-synced triggers twice
  68. WordPress not working on localhost
  69. Adding functions to hooks from within a class
  70. how to use hook deleted_user into custom function to delete user from custom table
  71. Disable The Events Calendar plugin from loading its scripts
  72. Where to store the name of a custom table?
  73. Applying OO patterns and principles to plugin development
  74. WordPress is automatically linking plain text email addresses
  75. Is Using WordPress Supplied WYSIWYG Advisable?
  76. update post meta for checkbox in the admin when inserted in the front-end
  77. ServerSideRender and Media Object: attributes passing image data object to php renderer even though it’s not set
  78. 403 Error when text is pasted in Custom Metabox Textarea
  79. WordPress database error for query INSERT INTO
  80. How to connect to AWS RDS external database (not for the core WordPress db)
  81. Is it possible to change a term slug before being saved to the database?
  82. Maximum lifetime for nonce
  83. Clearing caches on plugin uninstall
  84. How to use a hook to override an update_post_meta call in a plugin?
  85. Add code inside specific wordpress standard function
  86. Custom Taxonomy to dropdown box on adminside wordpress
  87. Create a free scripts and styles template within a plugin
  88. Saving value of a selection option in comment form as comment meta
  89. Add a Save Button to Custom Meta Box [duplicate]
  90. How to modify the comments to be displayed in a post?
  91. Plugin with action ‘save_post’ needs to press publish twice on order to publish
  92. How can I turn a custom wordpress page into a product page?
  93. How can we display product price $104 on the cart while the credit card payment method is checked?
  94. Incorporate small angular feature in my wordpress site
  95. How to Bind one post object Type with other postobject Type in Advanced Custom field [closed]
  96. Doubts about the use of metadata and how this can affect performance on WordPress
  97. update_post_meta not working in a loop
  98. Run Shortcode of post’s custom field in functions.php / Plugin
  99. How to add user details to different tables immediately after user registration
  100. Search: how to extend the existing search to include a custom table
Categories plugin-development Tags customization, mysql, plugin-development, post-meta, post-type
Override the else part of the index.php loop.
WordPress Query Crashes Browser

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