Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm doing a custom page that has multiple wp query calls, the thing is that I don't need the main query that is I don't need anything from the page contents, so in order to save load time I was wondering how to tell wordpress not to fetch anything from the db ?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I would highly recommend you to make one of those wp query calls the main query & all others as secondary queries. That will make your life much easier in the long run.

If you absolutely want to disable the main query, wordpress doesn't have a direct filter for that. You can however do a trick to achieve that
1) hook into parse_request action
2) Examine the request variables to determine if you are on the correct page
3) If you are not on the correct page, use return; & let wordpress go its normal route
4) do your custom wp query calls & output the HTML
5) use die(); to stop php execution

This should work, however you should note that, since wordpress never got a chance to populate the global variables, accessing them directly or via some core wordpress function will have unexpected results. Next, some plugins may also have problems. Make sure you carefully test all of the code you're using.

share|improve this answer
    
I found the answer on the 'request' filter. I was trying to create something like a custom archive page, the 'parse_request' can't change the entire query. Thanks. –  Poxtron Mar 15 '13 at 21:03

Your Answer

 
discard

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.