query_posts()

While the clock has started ticking on the 3.5 release grace period for Guidelines updates, I would like to discuss formalizing one other _doing_it_wrong() issue that has been implicitly enforced for some time now: use of query_posts().

Would anyone be opposed if we formally added query_posts() to Theme Check as a required stopper?

To understand why query_posts() is always inherently _doing_it_wrong(), see @nacin‘s WordCampWordCamp WordCamps are casual, locally-organized conferences covering everything related to WordPress. They're one of the places where the WordPress community comes together to teach one another what they’ve learned throughout the year and share the joy. Learn more. presentation You Don’t Know Query, and this great WordPress StackExchange answer by @rarst.

In short, if you are creating secondary queries, you should use WP_Query(), and if you’re modifying the main query, you should filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. pre_get_posts.

Thoughts?

#discussion, #guidelines