exclude category from Search
-
hi ?? i want to exclude category from Search i want to just show 1 category in my blog + in my Search to ther any plugin for it or any code to do it?
i did try many code like this one
<?php
add_filter( ‘pre_get_posts’, ‘ja_search_filter’ );
/**
* Exclude category 7 from search results.
*
* @since ?.?.?
* @author Jared Atchison
* @link https://gist.github.com/1300302
*
* @param WP_Query $query Existing query object
* @return WP_Query Amended query object
*/
function ja_search_filter( $query ) {if ( $query->is_search && !is_admin() )
$query->set( ‘cat’,’-7′ );return $query;
}
its not working can someone help me ??
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘exclude category from Search’ is closed to new replies.