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
- Can i use php sql functions instead of $wpdb?
- $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?
- I want to select the from values from database in WordPress? [closed]
- 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
- Multiple meta_key in one global $wpdb;
- 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?
- Issue with fetching mysql data and displaying results via shortcode in webpage
- 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?
- WPDB secure custom form
- What is the correct way to search 3 custom fields only in WordPress?
- 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
- How to center all text body in single.php at once?
- 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 do I get the featured post to share on Social Media and show on Individual Post pages?
- 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
- MySQL queries in WordPress
- 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?
- posts_clauses drop ACF get_field function
- 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
- Error resetting database index using ALTER TABLE in $wpdb->query
- 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?
- How to change post date and post time in WordPress automatically with a function
- Global update of records after import WP All Import Pro
- How to properly prepare a column name if passed to a stored procedure?
- Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder
- Trouble getting wpdb to work – first time