Filters on the Search Form

  • Author
    Posts
  • tomasbrescia

    Hello!

    First of all i wanted to thank you all for the awesome plugin you have made.

    I wanted to know if it’s possible to add the attribute filters on the Search Form (On homepage).

    Thanks!

    ihordeveloper

    Hi,

    Thanks, glad you like it!

    There’s no such option at the moment (it will be added later), but it’s possible with a simple code snippet. If you added some attribute and it’ll fit into the search bar (for example if it’s a simple text or number field) please send its slug (if there’s no slug field you can click “Screen Options” at the top of the page and select the “Slug” to be displayed) and I’ll post the code snippet that’ll add this attribute to the search bar.

    danieloliver

    Hi ihor, could you post the code snippet for this please? I’d like to add attribute with slug ‘colour’ to mine.

    ihordeveloper

    Sure, this code snippet should work:

    add_filter(
    	'hivepress/v1/models/listing/attributes',
    	function( $attributes ) {
    		if ( isset( $attributes['colour'] ) ) {
    			$attributes['colour']['searchable'] = true;
    		}
    
    		return $attributes;
    	},
    	1000
    );
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.