Filter to exclude pages results in "white" page on site and no errors in the log
function mySe开发者_Go百科archFilter($query) {
if ($query->is_search) {
// Exclude PlugStore from Search
$mypages = get_pages('child_of=1284');
$idlist = array(1284);
foreach ($mypages as $pagg) {
$idlist[] = $pagg->ID;
}
$query->set('post__not_in', $idlist);
}
return $query;
}
add_filter('pre_get_posts','mySearchFilter');
I have adjusted this question as I fixed the "white page" problem, but the code is still not excluding the pages whose parent page is 1284. Can any one spot my mistake please.
精彩评论