By default, Agile Store Locator displays all available categories in the category filter. If you only want visitors to browse specific categories, or you want to hide selected categories, you can control this directly through the shortcode.
Since Agile Store Locator 5.3.1, you can also exclude one or more categories using the new exclude_categories shortcode attribute.
Display Only Selected Categories #
Use the category shortcode attribute to display only specific categories in the category filter.
Separate multiple category IDs with commas.
[ASL_STORELOCATOR category="5,6,7,8,9,10"]
The example above displays only categories 5, 6, 7, 8, 9, and 10, along with their associated store locations.
Display a Single Category #
To display only one category, provide a single category ID.
[ASL_STORELOCATOR category="8"]
Only category 8 and its stores will be available in the Store Locator.
Exclude Specific Categories (Since 5.3.1) #
Starting with version 5.3.1, you can hide one or more categories while displaying all remaining categories.
Use the exclude_categories shortcode attribute with comma-separated category IDs.
[ASL_STORELOCATOR exclude_categories="8"]
Only category 8 will be excluded.
[ASL_STORELOCATOR exclude_categories="46,47"]
The example above hides categories 46 and 47 from the category filter while displaying every other category.
You can exclude as many categories as needed.
Filter Categories Programmatically #
If you need to change the displayed categories dynamically, you can use the asl_filter_locator_attrs filter in your active theme’s functions.php file.
/**
* [asl_filter_locator_method Change the Categories of the category attribute]
* @param [type] $attrs [description]
* @return [type] [description]
*/
function asl_category_change_event($attrs) {
global $wpdb;
$attrs['category'] = '1,2,4,5';
return $attrs;
};
add_filter('asl_filter_locator_attrs', 'asl_category_change_event');
The example above overrides the shortcode and always displays categories 1, 2, 4, and 5.
Required Shortcode Attribute #
The asl_filter_locator_attrs filter runs only when the shortcode already contains the corresponding attribute.
For example:
[ASL_STORELOCATOR category="1"]
Although the shortcode contains category 1, it will be overridden by the filter and the categories defined in functions.php will be used instead.
