Alternative to query_posts for main loop

Posted by Prem Tiwari | Updated on

That filter is only run for the main query, so that solves the problem with ‘pre_get_posts’, which fires for every query.

The downside is that you don’t have access to query flags like is_single() etc. Here’s one way you could get access to them, without actually doing the SQL queries:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers