Filters /

Facets

Facet filtering is a type of search filter that allows users to narrow down their search results quickly while preventing zero results from being returned. The facets (or filters) dynamically adjust on the fly based on the user’s previous selections and provide visual feedback about the remaining options – view example.

The Filters add-on provides functionality for implementing a faceted search experience.


Getting Started

The initial setup for implementing Facets in Ajax Load More is easy – all it requires is a couple of settings to be configured in the Options section of a Filter.

Implementation Steps

  1. Check the Enable Faceted Filtering option to activate facet functionality on the filter.
  2. Select your target post types from the Post Types listing.
    Note: The Post Types selected should be the same post types that are being displayed in your main Ajax Load More listing.

Facets can be enabled on any new or existing Filter instance that uses supported field types and query parameters.

Once a facet has been enabled on a filter, Ajax Load More will handle the indexing and updating of the frontend display.

Result Counts

Display dynamically updating result counts for each facet selection by enabling the Result Count option in a filter group.

Display Result Count facet option for Ajax Load More

Note: Result counts are required to be enabled on each filter group individually.


Field Types

The following field types are supported when using the faceted filtering in Ajax Load More.

  • Checkbox
  • Radio
  • Select
  • Select Multiple

Other field types, such as Star Rating and Range Slider will be supported in a future release.


Query Parameters

The following filter query parameters are supported when using the faceted filtering in Ajax Load More.

  • Taxonomy
  • Custom Fields
  • Tags
  • Tag__and
  • Category
  • Category__and
  • Post Type
  • Authors
  • Year
  • Month
  • Day

Filter Hooks

The following filter hooks are available when using facets functionality.

alm_filters_facets_index_{id}_args

This filter provides a method to modify the query args used for creating the facet index.

  • id: The unique filter ID.
add_filter( 'alm_filters_facets_index_movies_args', function( $args ) {
   // Filter ID = movies
   $args['tax_query'] = [
      [
         'taxonomy' => 'actor',
         'field' => 'slug',
         'terms'  => 'brad-pitt',
      ]
   ]; 
   return $args;
}, 10, 2 );
PHP

Note: This hook is helpful for filter instances where the facet index doesn’t need to include all possible post IDs.

alm_filters_facets_transient_expiration

This filter provides a method to adjust the facet transient expiration time.

add_filter( 'alm_filters_facets_transient_expiration', function() {   
   return DAY_IN_SECONDS; // Default = 7200
});
PHP

alm_filters_facets_posts_per_page

This filter provides a method to adjust the default indexing posts_per_page value which is -1.

add_filter( 'alm_filters_facets_posts_per_page', function() {   
   return 999; // Default = -1
});
PHP

Facet FAQs

Below are common questions regarding Ajax Load More facets. If you have a question and don’t see an answer here, please visit the support page and submit your request.


« Back to Filters