i want to remove a certain query in wp 3.1

add_filter( 'query', 'remove_delete_7_day_draft_queries' ); 

function remove_delete_7_day_draft_queries( $query ) { 
    global $wpdb;
    $q = "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date";
    if ( $q == $query) {
        return false;

    return $query; 

but in the error log i see something like this: WordPress database error Query was empty for query made by get_default_post_to_edit

any ideea how to remove the execution of the query without any error ? tx

1 Answer 1


I'm assuming you're talking about this piece of maintenance code right here:


Indeed, the code calls on lower level functionality of $wpdb, which doesn't contain too many hooks, only one in fact, query.


So, in order to return an empty result set you'll have to come up with a no-operation type of query, here are some examples:

  • SELECT NULL; (returns 1 NULL result)
  • DO 0;
  • SET @ignore_me = 0;
  • SELECT * FROM `$wpdb->posts` WHERE 1=0;
  • tx , i'm going with SELECT * FROM $wpdb->posts WHERE 1=0;
    – user416096
    Commented Apr 9, 2012 at 13:28

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.