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?


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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.