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 the following query and i can't find where is executed

SELECT count(ID) FROM wp_posts  WHERE 1=1  AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC;

Does anybody know where could be executed?

share|improve this question
And how do you know that you "have that query"? – kaiser Apr 13 '12 at 12:40
from the slow query log – user416096 Apr 13 '12 at 13:02
What the heck is "slow query log"? – kaiser Apr 13 '12 at 14:35
Ok... and where and how did you output it? – kaiser Apr 15 '12 at 0:42

It is not hard to log queries performed by WordPress. Simplest way would be to use plugin such as Debug Bar that collects backtrace information about where in code was query performed.

share|improve this answer
i need to locate the page where is executed not to check all possible pages with debug bar – user416096 Apr 13 '12 at 13:03
@user416096 unless you are doing some specific and varied coding in your pages, most of queries are usually part of load and do not differ much. I would suggest you at least try this for starters. – Rarst Apr 13 '12 at 13:05
i have found all the slow queries in the code without the debug bar, but this one seems impossible to locate i'm using wp 3.1 – user416096 Apr 13 '12 at 13:15
Upgrade to wp 3.3, 3.1 is old and insecure – Tom J Nowell Apr 13 '12 at 13:44
Debug bar should be able to tell you where the code is for that query, find the query using debugbar then look at its trace to see where it is being called from. – Tom J Nowell Apr 13 '12 at 13:45

If any tool/plugin doesn't help, open your favorite text/file editor, go for find text (usually ctrl+f or F3) and paste SELECT count(ID) FROM wp_posts WHERE 1=1 and find in all files i.e wordpress folder....... try with different combination which you think is specific with query in question....

share|improve this answer

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.