According to the Codex, the delete method will not accept the LIKE
operator. You’ll be better off just using the query method.
$query = $wpdb->prepare("DELETE FROM $wpdb->posts WHERE post_type="flamingo_inbound" AND post_content LIKE %s", '%'.$mail.'%');
$wpdb->query($query);
Hopefully $mail
doesn’t have a % or _ character otherwise you need to escape it before you build $query
like so:
$mail = $wpdb->esc_like($mail);
Related Posts:
- Can’t get wp_insert_post to work
- WSoD being caused by this piece of code
- $wpdb returns duplicate posts
- form $_post action value gets truncated after it passes through two forms
- Passed variable gets undefined variable error on insert on next page
- How to return number of found rows from SELECT query
- $wpdb->delete column values IN ARRAY()?
- Custom query to get post names beginning with a digit
- Custom SQL query to get List of posts with featured image url
- Delete post revisions on post publish
- Disable External Pingacks on WordPress Posts and Only Allow ‘Self Pings’
- Is the regular ajax request method safe or I should use admin-ajax.php?
- Successful or Error Message after running mysql code in functions.php
- New Plugin Review
- Use template for posts with a particular category grandparent
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- Insert all post IDs in new database table
- Styling images coming from another blog
- WordPress get pagination on wpdb get_results
- Ajax $wpdb not returning table data
- Converting MYSQL to WordPress $WPDB
- PHP code inside shortcodes
- Why is variable not working on custom sql query using wpdb?
- Show MySQL errors that occur when I excute $wpdb->insert()
- Query all posts of a custom taxonomy term
- Display fields as values in array from external SQL DB
- Trying to establish connection to External Database
- How to insert a single row to WP database table?
- Get post id in a function when edit/add a post
- How to check if a meta value has already been assigned to any user?
- wp_trim_words() does not work with my code Am I doing any mistake in my code?
- Update results, Before deleting the related category [closed]
- wp query foreach deleting record returning only first or last item
- Database query works fine outside WordPress
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- $wpdb->wp_users returning empty value for
- $wpdb->insert() does not Insert record in a table
- Help with a $wpdb MySQL Query
- Which PHP page is the Default Posts Page
- Custom array from a query only write the last row of the query
- Function works everywhere, how to keep it to execute when creating a new post
- Pagination on Custom Post
- Mixing variables into an array when inserting values
- Use $wpdb or other PHP script method to find/replace in WP database
- How can I add a new row in a separate database when someone registers via WordPress?
- Basic wpdb update question
- I can’t update my data through $wpdb
- Output: “Array”
- Reading settings in the home page precisely home.php
- get post id from wp_insert_post for get_template_part
- How do I prepare strings for insertions as values into a MySQL table?
- How to use AJAX in WordPress in MYSQL query?
- Change MySQL PDO connection to a WPDB connection
- Why won’t this wpdb get_results query return results?
- Why when I create a new post I found 2 record related to this post into the posts database table?
- Add row to custom database Table and delete all rows older than 1 day
- select a single val though a table in wordpress
- making php value numeric
- populate select options from extra mysql table data
- MySQL Query Returns Array () In Shortcode
- remove specificly the last tag in all posts
- Modify WooCommerce used to get all orders in dashboard
- Add posts to custom table in database instead of wp_posts
- Passing in MySQL prepare statement parameter separately throwing error
- Convert a column of a table containing an Array as response in HTML
- Database SQL query error
- How to Send Pingbacks for all Posts in WordPress?
- posts_per_page displays only 2 posts instead of 4 posts
- MYSQL TIMESTAMP when adding DATE_FORMAT then the output is blank, PHP conflict?
- Conditional formatting on data fetched from MYSQL
- Using wpdb to connect to a different database is not working
- Send POST request to Flask app from functions.php file
- Change upload URL by mime type
- Modify post image in full size
- WordPress post insertion from PHP file
- Getting page / post URL on publish and / or update
- Displaying POST content with HTML tags and all
- Rewrite SQL query as a prepared statement and use in foreach loop
- Advanced WordPress SQL Query
- Using Tag Groups: Displaying groups and adjacent tags of current post
- How can I display a query in a page?
- MySQL query in WordPress with AJAX
- insert thumbnail image from php script
- Can’t put a hyperlink on Featured Post’s Image
- How to set up an auto delete post?
- Weird Behaviour: Not all WordPress Posts appearing
- Published custom posts missing
- WordPress get_post_meta issue
- Insert wordpress tags below posts via functions.php
- Using the same shortcode to show any table from the database
- Trying to see if page is category or single and displaying title with appropriate heading tag
- MySQL database migration to WordPress
- How to modify this function to exclude also the post belonging to a specific category?
- How to display the date under the post title?
- Add multiple HTML attributes to an Elementor button
- WooCommerce: write featured image dimensions to custom fields in product’
- How do I get a function to work in single.php
- transition_post_status hook, works – but not if the post is new
- Putting form result in my database
- How can I update a value of a field depending on outside source?