WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Search Everything] Not working for multiple terms (1 post)

  1. Seijun
    Member
    Posted 3 years ago #

    I am trying to search taxonomy terms. I have Search Everything set to search taxonomies and it works well for only one term. For example, if I search "blue", all posts with the tax term "blue" show. However, if I try to search TWO taxonomy terms, I don't get any results. For example, a post with "Color: Blue" and "Size: Large" won't show up in a search for "blue large" but will show in a search for "red" or "large" if searched separately. Is there a workaround for this?

    I tried adding this to my function.php (found in another topic) but I'm not sure how to use it.

    // MULTIPLE TAXONOMY SEARCH
    function posts_search ($post_type,$taxonomies) { // $taxonomies should be an array ('taxonomy'=>'term', 'taxonomy2'=>'term2')
    	foreach ($taxonomies as $key=>$value) {
    		$args=array('post_type'=>$post_type,'post__in'=>$ids,$key=>$value);
    		unset($ids); $ids=array();
    		foreach($posts=get_posts($args) as $post) { $ids[]=$post->ID; }
    		if (empty($ids)) return false; // no matches left don't bother continuing
    	}
    	return $posts; // we made it: return matching posts
    }

    Searching for multiple terms still returns no results.

Topic Closed

This topic has been closed to new replies.

About this Topic