Are there any scenarios where the query_posts may be used?

query_posts() is useful in cases when there is no main query: calls to wp-admin/admin-ajax.php, wp-admin/admin-post.php or wp-login.php for example.

Yes, you can achieve the same results there without query_posts() and slightly less compact code instead. But if you don’t have to care about side effects, using query_posts() is acceptable.

Leave a Comment