请尝试以下代码:
$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();