I have a custom post type ‘listings’ and within that a taxonomy called ‘status’ where the posts are either ‘standard’ or ‘premium’.
What SQL query (or other method), could I use to delete all custom posts where the taxonomy ‘status’ has the value ‘standard’ ?
Thank you.
something along these lines should do it:
$args = array(
'post_type' => 'listings',
'posts_per_page'=> -1,
'post_status' => 'any',
'tax_query' => array(
array(
'taxonomy' => 'status',
'field' => YOUR FIELD NAME HERE???
'terms' => 'standard'
)
)
);
$query = new WP_Query( $args );
foreach( $query->posts as $id ){
wp_delete_post( $id->ID, TRUE );
}