• Hello

    Is there any way to unset default wp db query:

    SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 10

    since I’m executing my custom query with $wpdb->get_results()?

    The reason is that my custom query is quite complex and I don’t need the default query which is still persist and I’d like to minimize database queries as possible.

    thanks,
    K.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Have you read this guide to custom queries?

    Also, what do you mean that it “still persists”?

    Thread Starter yoch

    (@yoch)

    rjmastey, thanks for the answer.

    Yes, I read this. When I have my custom query setup and working, While debugging queries that was made to DB I still can see this ‘regular’ query:

    SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 10

    I mean that I don’t need that ‘default’ query anymore, because I got the results with my own query.

    How to tell WP to stop executing it?

    thanks,
    K.

    Thread Starter yoch

    (@yoch)

    bump..

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to unset default query when using custom query’ is closed to new replies.