Let’s suppose you have a large list of the categories. Moreover, if you want to display only a few of them and ignore the rest, you can do with the shortcode attribute category. Use it (shortcode attribute category) in the shortcode with the comma-separated values of the categories.
[ASL_STORELOCATOR category="5,6,7,8,9,10"]
With the shortcode above, it will display only 5,6,7,8,9,10 categories and their respective stores.
To show just one category over the map, write the ID of that category in the category shortcode attribute.
[ASL_STORELOCATOR category="8"]
How to implement it via attributes filter? #
In order to implement the above category filter via programatically, you can copy and paste the code into your active theme functions.php.
/**
* [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');
Please make sure to add some shortcode attribute within your shortcode so that the change event can fire, such as change your default shortcode to this.
[ASL_STORELOCATOR category="1"]
The 1 ID in the above shortcode will not be used, it will be overriden by the functions.php value.