{"id":4433991,"date":"2013-12-20T16:38:28","date_gmt":"2013-12-20T16:38:28","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/upgrade-to-38-breaking-is_main_query-function\/"},"modified":"2016-08-21T13:43:40","modified_gmt":"2016-08-21T13:43:40","slug":"upgrade-to-38-breaking-is_main_query-function","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/upgrade-to-38-breaking-is_main_query-function\/","title":{"rendered":"Upgrade to 3.8 breaking is_main_query() function"},"content":{"rendered":"<p>I&#8217;m using the &#8220;pre_get_posts&#8221; hook to modify the WordPress query for 2 specific categories on a site. Everything is working fine until it gets to this point:<\/p>\n<pre><code>if($query-&gt;is_main_query()) {\n\t$query-&gt;query_vars[&#039;post__in&#039;] = $pageposts_arr;\n\t$query-&gt;query_vars[&#039;orderby&#039;] = &#039;post__in&#039;;\n}<\/code><\/pre>\n<p>$pageposts_arr is just an array of post IDs in a specific order determined by a special mysql query. I&#8217;ve tried both $query-&gt;is_main_query() and is_main_query(), neither return any value. Everything works fine if I remove the if test, except that it breaks all the other queries on the page. I can confirm that it was working fine in 3.7, and broke immediately upon upgrading to 3.8.<\/p>\n<p>Been searching for quite a while, but noone else seems to be having this problem. Anyone know what&#8217;s up?<\/p>\n","protected":false},"template":"","class_list":["post-4433991","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4433991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4433991\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=4433991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}