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 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

share|improve this question
up vote 1 down vote accepted

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;
share|improve this answer
tx , i'm going with SELECT * FROM $wpdb->posts WHERE 1=0; – user416096 Apr 9 '12 at 13:28
@user416096 don't forget to accept an answer. – soulseekah Apr 9 '12 at 22:59

Your Answer


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.