• Hi,
    I added the following snippet to functions.php to include the tag search

    add_action( 'pre_get_posts', 'include_tags_in_search' );
    function include_tags_in_search($query){
        if($query->is_search){
            $terms = explode(' ', $query->get('s'));
            $query->set('tax_query', array(
                'relation'=>'OR',
                array(
                    'taxonomy'=>'post_tag',
                    'field'=>'slug',
                    'terms'=>$terms
                )
            ));
        }
    }
    

    It works but the search results include results from all languages. What should I add to the snippet to filter only the results of the language in which I search? Thanks

Viewing 1 replies (of 1 total)
  • You need to add the language to the query with an AND relation. I recommand using your prefered search engine to find out how to do it.

Viewing 1 replies (of 1 total)
  • The topic ‘search results (tags) in all languages’ is closed to new replies.