Change of query var in pre_get_posts not maintained

The init hook runs well before pre_get_posts so dumping the query at that point– on init— isn’t going to reflect anything that will be done much later. I don’t think there is anything wrong with your code, you misunderstand the sequence of actions. What you expect to happen isn’t what actually happens.

Leave a Comment