Please try with below code :
$pro_args = [];
$pro_args['post_type'] = 'post'; //Replace your post type
$pro_args['post_status'] = 'publish';
$pro_args['posts_per_page'] = -1;
$pro_args['tax_query'] = array(
array(
'taxonomy' => 'category', //Replace your taxonomy name
'field' => 'id',
'terms' => array( 66 ),
)
);
// Optional
$pro_args['meta_query'] = array(
'relation' => 'AND',
array(
'key' => 'key1',
'compare' => 'EXISTS',
)
);
$pro_query = new WP_Query( $pro_args );
if ( $pro_query->have_posts() ) {
while ( $pro_query->have_posts() ) { $pro_query->the_post();
delete_post_meta( get_the_ID(), 'key1' );
}
}
wp_reset_postdata();
Related Posts:
- importing data from non-wordpress mysql db
- Query meta field using between
- Move value of one custom field to another
- Get multiple custom field values in a $wpdb query [duplicate]
- Difference between ‘LIKE’ and ‘IN’ in meta queries
- little help with a mySQL query to wp database
- Importing users to Buddypress with custom fields
- MySQL query to set wp_postmeta using term_taxonomy_id value
- MySQL Query that looks for post with Custom Field, then changes Category
- Unique Post Meta Values
- Add custom field to all posts in specific post_type
- UPDATE on SELECT results. A SQL query to swap Author with Meta Box value
- Importing WordPress Posts With Custom Meta Data As CSV Files Through PHPMyAdmin
- Inserting data into MagicFields using mysql queries
- Copy price categories to custom field
- If I update WordPress my custom data will be deleted from the wp_users table?
- Update post meta data (custom field) by post link
- Help setting up a sql query
- wpdb function insert doesn’t work
- How to improve my non-unique metadata MySQL entries?
- use mysql to replace one custom field value with another custom field value
- Copy url from post_content to custom field
- Convert many posts from having a specific meta_key to use a post_format
- Custom Search, MySql Query Gone Wrong?
- Can running a WP-Cron to update_post_meta cause performance issues?
- How can I avoid re-inventing the Custom Fields wheel in my Plugin’s Metabox?
- Using wordpress post data as input for google visualisations
- Does wordpress have something like content-type?
- Order Posts by Closest Numeric Values
- How to get and edit custom fields if in Quick Edit
- Order posts by custom field and if custom field is empty return remaining posts
- Can serialized arrays in DB be matched against serialized arrays with meta_query?
- Create custom field on post draft or publish?
- Adding a prefix to a post title
- copy attachments to another post type and change attachment url
- Cannot edit post meta fields with rest API
- Only display custom field if it there is a value inside
- Add a post meta key and value only if it does not exist on the post
- Custom field values repeating
- Sorting posts by multiple values, combined
- WP_Meta_Query causing long-running MySQL queries
- Separate table or usermeta
- trim custom field text value and show (…)
- Duplicate posts being displayed when querying Custom Fields
- Json api does not return all metadata
- Use custom field as a variable
- ACF: How to get the full field name (meta_key) by a field key?
- Tweak Meta for Post to work it for Pages also
- Adding an editable field to template?
- Transferring author information from a custom field to a proper author
- How to select posts from multiple categories and metavalues?
- Is there a simpler version of WP Media?
- modify wordpress caption shortcode
- Alter main archive, to show posts with meta as last
- Add microdata from schema.org [closed]
- Displaying multiple URLs as custom field values
- Linking Custom Fields to Database Records
- How can I save custom meta to one global value?
- Stop sending email everytime I updates my post
- Best way to store everyday post views?
- How to use media upload on metabox post page without breaking TinyMCE?
- Branch made by several custom values
- How can I activate custom fields checkbox in pages?
- Insert image into sub-field with update_post_meta
- Show custom field on attachment page?
- How to use conditional statement with custom field
- WP Insert post with post_thumbnail
- Custom meta boxes in RSS feed
- SQL: Select wordpress posts with given text string and add a custom field to them?
- custom comment_form fields not displaying
- WP_Query () using taxonomy, custom post types
- Ordering by ‘Title’ OR ‘Custom Field’
- How can I add/update post meta in a admin menu page?
- pull all posts’ meta key values from current category only
- Is it possible to use get_post_meta() to control HTML?
- Editing custom fields for comments
- Compare ACF date field (if exists) and post date and order DESC
- Add WordPress user custom meta to chartjs vertically stacked chart in Divi theme
- What am I missing in this Code Block?
- Making WP_Query limit results by date before today where date is a meta_query
- Shortcode for Custom Field of Media Attachment (to use with Featured Images)
- Weird custom fields data lost
- Showing the post only when there is title, thumbnail and the content in Custom Fields
- WooCommerce 3 get custom variation on process order [closed]
- query_posts -> get page_id from custom field
- Custom field group on page
- Output Custom Field value to shortcode
- Update custom table on metabox POST
- display custom media folders to wordpress media popup
- change attachment custom field onChange event
- Custom Meta Boxes and Fields for WordPress: Change directory upload based on user-edit page
- How to filter post using custom feild value in shortest and longest duration?
- Get custom field from other post in carousel
- Form fields based on custom fields
- show custom field content in jquery tabs
- Create citation and url in post using 3 custom fields with conditions for each field… So close!
- Advenced custom fields auto fill problem
- woocommerce how in checkout to add my custom field check box, and when i check it hide the shipping adress and add tax 19% [closed]
- Show only first image of multiple image field
- Custom Fields after update to WordPress 6