WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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.