{"id":6721015,"date":"2015-11-05T19:55:08","date_gmt":"2015-11-05T19:55:08","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/custom-query-breaks-template\/"},"modified":"2016-08-30T19:56:14","modified_gmt":"2016-08-30T19:56:14","slug":"custom-query-breaks-template","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/custom-query-breaks-template\/","title":{"rendered":"Custom query breaks template"},"content":{"rendered":"<p>Hi if you go to http:\/\/sowingkindness.com\/most-inspirational-stories-for-kids\/ you&#8217;ll see the layout is broken by a custom query I&#8217;m trying to run, sorting posts by a meta value.<\/p>\n<p>Some posts are span8 and others are span12, sometimes the sidebar just doesn&#8217;t show up.<\/p>\n<p>My query is<\/p>\n<pre><code>$query = new WP_Query(array(\n    &#039;post_status&#039; =&gt;&#039;publish&#039;,\n    &#039;post_type&#039; =&gt;&#039;post&#039;,\n    &#039;orderby&#039; =&gt; &#039;meta_value_num&#039;,\n    &#039;meta_key&#039; =&gt; &#039;_liked&#039;,\n    &#039;paged&#039; =&gt; (get_query_var(&#039;paged&#039;)) ? get_query_var(&#039;paged&#039;) : 1\n    ));<\/code><\/pre>\n<p>I put it before anything else, right after the template name.<\/p>\n<p>Then I call <code>if ( $query-&gt;have_posts() ) :<\/code> etc etc<\/p>\n","protected":false},"template":"","class_list":["post-6721015","topic","type-topic","status-publish","hentry","topic-tag-custom","topic-tag-template"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6721015","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\/6721015\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=6721015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}