The search experience determines whether visitors find what they are looking for in your HivePress directory or leave frustrated. The default search shows a text field and location input. For most niche directories, that is not enough – a rental directory needs a price range filter, a restaurant directory needs cuisine type, a freelancer directory needs skill tags and hourly rate range. This guide covers how to configure each type of filter correctly.
How HivePress Search Filters Work
HivePress connects search filters directly to listing attributes. Every filter you add in the search form corresponds to an attribute field on the listing. This means the setup process is always the same two steps: create the attribute with the right field type, then mark it as searchable. HivePress generates the filter UI automatically based on the attribute type – a select attribute becomes a dropdown filter, a checkbox attribute becomes a checkbox group, a number attribute becomes a range slider.
Understanding this connection prevents the most common mistake: adding a filter to the search form without first creating the corresponding listing attribute. A filter with no backing attribute returns no results regardless of how it is configured.
Step 1: Create Filterable Attributes
Go to HivePress -> Attributes -> Add New. The attribute field type determines what kind of filter appears in search:
- Select (dropdown with predefined options) – creates a dropdown filter. Best for: category-like attributes with a fixed list of options (cuisine type, property type, industry sector). Add your options in the Choices field.
- Checkbox (multiple selection) – creates a checkbox group filter. Best for: amenities, features, skills – things where a listing can have multiple values and visitors want to filter by any combination. A vacation rental with pool AND wifi is found by both the pool filter and the wifi filter.
- Number – creates a range slider filter. Best for: price, capacity, square footage, hourly rate. Set minimum and maximum values for the slider range.
- Text – not filterable as a range or dropdown; appears as a keyword search input. Only use text attributes for content fields, not filterable data.
Want this built properly from the start? Describe what you need and get a free estimate.
Step 2: Mark Attributes as Searchable
In the attribute settings, enable the “Searchable” checkbox. This adds the attribute to HivePress’s search filter system. Also enable “Filterable” if you want the attribute to appear in the search sidebar or filter bar on the listings page. The distinction: Searchable means the attribute is indexed for search, Filterable means it actively appears as a UI element in the search interface.
For attributes you want to filter by but not show prominently (like a backend categorisation field), enable Searchable but disable Filterable, then add the filter programmatically via a URL parameter.
Step 3: Configure the Search Form Layout
HivePress uses a template-based system for the search form. The default search form shows the text search and location fields. Adding custom filters to the main search form (the prominent form on your homepage or category pages) requires adding your filterable attributes to the search form template.
In HivePress -> Attributes, each searchable attribute has a “Search form” position setting. Set this to determine whether the attribute appears in the main search form (shown before results) or the filter sidebar (shown alongside results). For the most important 2-3 filters (the ones most visitors will use), put them in the main search form. Secondary filters go in the sidebar.
Step 4: Price Range Filter
A price range filter is one of the most common requirements for rental, freelancer, and service directories. Create a number attribute named “Price” (or “Hourly Rate”, “Daily Rate”, etc.). Set the field type to Number. Configure the min and max values to match your directory’s expected price range – if your rental directory has properties from $50/night to $2000/night, set the slider range accordingly.
Mark the attribute as Searchable and Filterable. HivePress automatically creates a range slider for number attributes in the filter sidebar. Vendors enter their price when submitting a listing. The filter returns listings whose price falls within the selected range.
One limitation to be aware of: HivePress’s default number filter uses exact range matching. If a vendor enters “150” as their price and a visitor sets the filter from 100-200, the listing appears. But if the price is stored as a string (due to formatting issues during submission), the comparison may fail. Always validate that price submissions save as numeric values in the database by checking a submitted listing’s meta data in the WordPress admin.
Step 5: Location Radius Search
HivePress’s Geolocation extension (free) adds a location field to listings and a location search input to the search form. By default, location search finds exact city or region matches. Radius search – finding listings within X miles or kilometers of a point – requires additional configuration.
The HivePress Geolocation extension supports radius search when a Google Maps API key is configured. Go to HivePress -> Settings -> Integrations -> Google Maps and enter your API key. Enable the “Location radius” option in search settings. Visitors enter a location and a radius, and HivePress queries listings within that geographic distance using the coordinates stored on each listing.
For the radius search to work, all listings must have coordinates (latitude and longitude) stored, not just a text address. When vendors submit a listing with the Geolocation extension active, they place a pin on a map or enter an address that is geocoded to coordinates automatically. Listings submitted before the extension was active need to be re-edited to add coordinates.
Adding Filters Programmatically
For filter types that HivePress does not support natively through the admin interface, you can add custom filters via code. This is useful for date range filters, tag-based filtering, or complex multi-attribute combinations. Add to your theme’s functions.php or a Code Snippets snippet:
// Add a custom filter for a specific attribute
add_filter('hivepress/v1/models/listing/fields', function($fields) {
$fields['custom_filter'] = array(
'label' => 'Your Filter Label',
'type' => 'select',
'options' => array(
'option1' => 'Option One',
'option2' => 'Option Two',
),
'_indexable' => true,
'_searchable' => true,
);
return $fields;
});
Verifying Filters Return Correct Results
After configuring filters, test each one systematically. Create listings with known attribute values – a listing with price 100, another with price 200, another with price 300. Set the price filter to 150-250 and verify only the 200 listing appears. Test edge cases: what happens when the filter range exactly matches a listing’s value (it should appear). What happens when no listings match the filter (the results page should show an empty state, not an error).
Use Query Monitor to inspect the database queries that HivePress generates for filtered searches. A filter query scanning all listings without using a meta index is a performance problem at scale. If you see full table scans on wp_postmeta for frequently-used filters, add a database index on the relevant meta_key to speed up the queries.