Support » Plugin: Events Manager » is_tax() not working for event-categories taxonomy

  • Hello,
    thanks for this great plugin.

    I think I have encountered a bug.
    In Events -> Settings -> Pages -> Override with Formats is set to “Yes”. This work great. But, when I want to use the is_tax() function on the taxonomy archive pages, that core function returns false, while it should return true.

    When I set the Override with Formats option to “No”, the is_tax() function return true, which is the expected behaviour. Since I like the default styling, I would like to leave the option to “Yes”.

    Is this a bug, or is there a workaround by using a custom is_tax() function?

    Thanks.

    https://wordpress.org/plugins/events-manager/

Viewing 4 replies - 16 through 19 (of 19 total)
  • Any update on this?

    mimo

    (@mimothemes)

    Hi, i was in need to solve this and found a way to do it, the thing is to look if we are in an Events Page, one of the Events page set in Events Manager Settings.

    To do this we try to see if we are in a page which id is one saved in Events Manager settings.

    if (! function_exists('mimo_is_events_page')) :
        function mimo_is_events_page($events_keys   =   array ( 
                "dbem_categories_page",
                "dbem_events_page" ,
                "dbem_locations_page" ,
                "dbem_tags_page" ,
                "dbem_bookings_page" ,
            ) )
        {
            if(!isset($events_keys)) :
                $events_keys   =   array ( 
                    "dbem_categories_page",
                    "dbem_events_page" ,
                    "dbem_locations_page" ,
                    "dbem_tags_page" ,
                    "dbem_bookings_page" ,
                ) ;
            endif;
            foreach ($events_keys as $wc_page_id) {
                if (get_the_ID() == get_option($wc_page_id, 0)) {
                        return true ;
                }
            }
                return false;
        };
    endif;

    The function can be used to see if we are in any of the Events Manager Pages like this:

    if( mimo_is_events_page() ) :
    
    //Do something
    
    endif;

    Also can be used to see if we are in a particular Events Page like this:

    if( mimo_is_events_page(array(dbem_categories_page) ) :
    
    //Do something because we are in Categories page of Events Manager
    
    endif;

    After this, to know in which category we are, or tag, we can use:

    $q_object = get_queried_objet();
    //Get Events Category object if it exists
     $mimo_event_cat = get_term_by('name', $q_object->post_title, 'event-categories');
    //Get Events Tag object if it exists 
     $mimo_event_tag = get_term_by('name', $q_object->post_title, 'event-tags');
     if ($mimo_event_cat) { 
        //Echo Events Category name
        echo esc_html($mimo_event_cat->name);
       
    } elseif(mimo_event_tag) {
        //Echo Events Tag name
        echo esc_html($mimo_event_tag->name);
    
    } else{
        //We are not in a category or tag page
    }
    
    

    Hope it can help someone.
    Best Regards

    Thanks, will try to use this as a workaround.

    Hello,

    any news on this?

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘is_tax() not working for event-categories taxonomy’ is closed to new replies.