Reply To: Custom Icon Per Term

Home Forums MapPress Support Custom Icon Per Term Reply To: Custom Icon Per Term

#15498
marijke
Participant

    Hi Chris and others,

    I had the same problem and solved it with help from these replies, but I changed the code a bit. First I set $iconid to zero, to be sure that all icons are reset to the standard. Than I set my terms from my custom taxonomy. Terms that are not set will get the default icon.

    
    function myiconid($iconid, $poi) {
    global $post;
    $postid = ($poi->postid) ? $poi->postid : $post->ID;
    $iconid=0;
    if (has_term('term1','mytax',  $postid))
    $iconid = 'term1.png';
    if (has_term('term2','mytax',  $postid))
    $iconid = 'term2.png';
    return $iconid;
    }
    add_filter('mappress_poi_iconid', 'myiconid', 10, 2);