Home Support General HivePress Filters on the Search Form

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!

    ihor developer

    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.

    ihor developer

    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
    );
    Okulo

    Good day.
    How can you make the same filter, only for the Cyrillic alphabet (Russian Language)?

    serhii developer

    Hi,
    Now you can mark any attribute as searchable in the Listings > Attributes section without any additional code snippets.

    Okulo

    Thank you serhii!
    This is a great solution. Just how to remove the (-) sign by default?
    or can it replace it with some value from the list?

    serhii developer

    You can do it in the Listings > Attributes > Search section. There is a “Placeholder” field for the “Select” type of attribute.

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

You must be logged in to reply to this topic.