Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

OniX777 on "After the upgrade does not work the filter categories"

$
0
0

I need for users (not administrators) to exclude from the site search a particular category. Code written, all worked fine until the latest updates. On what exactly update stopped working I do not know. Most likely 3.9 or 4.0.

Worked the following code:

function search_filter ($query) {
     if (($ query-> is_search) and! current_user_can ('administrator')) {
       $query-> set ('cat', '-14');
     }
}
add_action ('pre_get_posts', 'search_filter');

$query-> set ('category__not_in', '14'); does not work
add_filter - does not work

Code is inserted into the functions.php of the theme.

Anyone know why suddenly stopped working this code?


Viewing all articles
Browse latest Browse all 8245

Trending Articles