Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

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(
        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 );
      }
share|improve this answer
    
Thanks. I assume the field name would be 'slug'? –  Josh Jul 9 '12 at 11:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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