Custom Marker Category

This topic contains 5 replies, has 2 voices, and was last updated by  Stephen Harris 10 years, 3 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #8665

    Hi Stephen, I’m sure I saw an article you wrote somewhere about custom markers per category. I’m assuming this would work for tags as well, if the only thing changing is the taxonomy? How would i go about it? I have Pro + the marker add on.

    Ardin Beech
    #8684

    Hi Ardin,

    Because the maps are associated with venues and not events there’s ambiguity about which event to use to get the appropriate category. The same is true for tags. In the article I suggested you can use the next event to happen at that venue, but it may also be possible to use the ‘current event’ (when used inside the loop) – (admittedly, I’ve not tried).

    Are either of those what you were thinking?

    Stephen Harris
    #8990

    Hi Stephen, sorry the late reply; I’ve been on holidays.
    My case is a little different I guess, because it’s a site for open houses, so each event is tied to venue only once: the venue being the open house address, the event being the open house time. Once it’s over, the venue is never used again, unless of course the house is listed again at a later date. So can the venue marker somehow get pulled from the event tag? (real estate agent)

    Ardin Beech
    #8991

    Hi Ardin,

    If there’s a 1-1 correspondence between event and venue, why not store the marker the venue page. Or is it possible a house maybe listed again but require a different marker. But anyway, here’s how you could do it:

    add_filter( 'eventorganiser_venue_marker', 'my_venue_map_icon', 10, 2 );
    function my_venue_map_icon( $icon, $venue_id ){
    
        //Get venue slug from ID
        $venue = eo_get_venue_by( 'id', $venue_id );
        $slug = $venue->slug;
    
        //Get event from venue
        $events = eo_get_events( array(
             'fields' => 'ids',
             'venue' =>  $slug,
             'showpastevents' => true,
             'numberposts' => 1,
        ) );
    
        if( $events) {
            //Event found, get its tags
            $event_id = $events[0];
            $tags = get_the_terms( $event_id, 'event-tag' );
    
            if ( $terms && ! is_wp_error( $terms ) ){
                //Event has tags, pick one.
                $tag = array_shift( $tags);
    
               //Set $icon (url to marker) to use for thetag $tag
            }
        }
    
        return $icon;
    }

    You’ll need to fill in the blanks though – specifically, given a $tag, what is the url to it’s marker. The easiest way is to have some sort of naming convention of marker images and a dedicated folder in wp-content for your markers.

    Stephen Harris
    #9044

    Thanks Stephen. Where would I insert the code?

    Ardin Beech
    #9062

    I’d recommend putting it in a dedicated plug-in – but it will work inside your theme’s functions.php.

    Stephen Harris
Viewing 6 posts - 1 through 6 (of 6 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.