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.

1 Answer 1


something along these lines should do it:

$args = array(
        'post_type' => 'listings',
        'posts_per_page'=> -1,
        'post_status' => 'any',
    'tax_query' => 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 );
  • Thanks. I assume the field name would be 'slug'?
    – Josh
    Commented Jul 9, 2012 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.