{"id":6828502,"date":"2015-12-09T10:57:31","date_gmt":"2015-12-09T10:57:31","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/error-with-pre_get_posts\/"},"modified":"2016-08-30T21:07:35","modified_gmt":"2016-08-30T21:07:35","slug":"error-with-pre_get_posts","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/error-with-pre_get_posts\/","title":{"rendered":"Error with pre_get_posts"},"content":{"rendered":"<pre><code>function search_filter($query) {\n\n\tif (is_search()) {\n\t\t$query-&gt;set(&#039;post_parent__not_in&#039;, array(560));\n\t\t$query-&gt;set(&#039;posts_per_page&#039;, -1);\n\t}\n\n\treturn $query;\n}\n\nadd_action( &#039;pre_get_posts&#039;, &#039;search_filter&#039; );<\/code><\/pre>\n<p>File function.php<\/p>\n<p>Nothing happens, the changes are not present. What could be the problem?<br \/>\nIf you insert exit() in check it works.<\/p>\n","protected":false},"template":"","class_list":["post-6828502","topic","type-topic","status-publish","hentry","topic-tag-function-php","topic-tag-pre_get_posts"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6828502","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\/6828502\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=6828502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}