Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if( ! function_exists( 'videotube_pre_query_search_result' ) ){
- /**
- * Filter the query of search result
- * @param $query
- */
- function videotube_pre_query_search_result( $query ) {
- if( $query->is_search() && $query->is_main_query() ){
- $query->set( 'tax_query',
- array(
- array(
- 'taxonomy' => 'categories',
- 'field' => 'id',
- 'terms' => array( 243 ), // an array of video category, e.g: array( 1,2,3,4 )
- 'operator' => 'IN'
- )
- )
- );
- }
- }
- add_action( 'pre_get_posts', 'videotube_pre_query_search_result', 10, 1 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement