How to add custom class names to the infoboxes

In this tutorial, you’ll see how to add custom class names to the infoboxes.

Edit the file “functions.php” of your theme/child theme and copy/paste one of the exemplary codes below, then, adapt it to your needs:

$default_content: The default infobox content .

$atts: Array that contains the map ID as $map_id and the post ID as $post_id.

Example 1: Adding simple class names to the inofboxes.

add_filter('cspm_infobox_custom_class', function($default, $atts){     
    return 'my_custom_class1 my_custom_class2; 
}, 10, 2);


Example 2: Using the post terms as new custom class names of the infoboxes.

add_filter('cspm_infobox_custom_class', function($default, $atts){ 
    extract(wp_parse_args($atts)); // Returns "map ID" as $map_id & "post ID" as $post_id 
    return strip_tags( implode(' ', wp_get_post_terms($post_id, 'category', array('fields' => 'slugs')))); 
}, 10, 2);

In the same context