Free Directory, Listing & Classifieds WordPress Plugin Support Extensions Tags Search by multiple tags works wrong

Search by multiple tags works wrong

  • Author
    Posts
  • blacklevel

    Example:

    Global tags: tag1 tag2 tag3 tag4

    Listing tags: tag1 tag2 tag3

    Search works, and find listing with:
    tag1
    tag1 tag2
    tag1 tag2 tag3

    Search does not work and cant find listing:
    tag1 tag4
    tag1 tag2 tag4
    tag1 tag2 tag3 tag4

    Why? Example: If listing has tag1, and user search for tags tag1 and tag4, results for tag1 must be shown (and alos results for tag4), but not only listings who have only tag1 and tag4 in the same listing.

    appliftr

    I had the same issue with attributes yesterday. For me this worked:

    Go to the tag (or attribute) page and scroll down to Search. You will find a checkbox under Options: Search any of the selected options. When you check that box, you should be able to get a result for every tag you search for.

    blacklevel

    appliftr
    thank you

    ihordeveloper

    This is not a bug – there’s the “and” condition for the tags filter instead of “or”, so users can narrow their search by selecting multiple tags. I guess I’ll add an option to switch this, please try using this code snippet until it’s implemented:

    add_filter(
    	'hivepress/v1/models/listing/attributes',
    	function( $attributes ) {
    		if ( isset( $attributes['tags'] ) ) {
    			$attributes['tags']['search_field']['filter_operator'] = 'IN';
    		}
    		return $attributes;
    	},
    	1000
    );

    You can add it to the child theme’s functions.php file or using this plugin https://wordpress.org/plugins/code-snippets/ Then listings with any of the selected tags will be displayed.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Subscribe

Sign In

Don't have an account? Register

Forgot password?

Register

Already have an account? Sign In

Forgot password?

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.