Support » Plugin: The Events Calendar » How to Identify Nav Menu Item for Events Calendar Page?

  • Resolved BrianCS



    I’d like to know how to identify whether the current page is showing the event calendar or not, so that I can highlight the appropriate menu item in my main nav menu.

    I’ve just installed The Events Calendar to a WP site I’m developing locally (on a laptop running MAMP), so it’s not publicly visible yet. I have instead provided a link to a live version of the site I will be replacing (which is just straight HTML + Bootstrap site); the new version I am working on uses very similar nav menu markup and CSS, so you can see what I’m talking about.

    In my nav menu, I use a custom WP menu creation function (because I use Bootstrap) to assign the “active” class to the current page’s nav menu link. This lets me specially highlight that menu item in CSS (i.e. instead of light grey, it’s in bright white with an underline). I noticed, however, that the is_page() PHP function does not return true when I go to the page with the events calendar. So when I go to the events calendar in the WP version I’m developing, all nav menu links show up in grey with no active class assigned.

    Since the events calendar technically does not seem to generate a page (i.e. no “events” page is created or shown in Pages in the WP Admin Panel), it makes sense that is_page() would not return true. However… how can I get my nav menu code to know to add the active class to the event calendar nav menu item? For instance, is there a way to do this with a function like is_single(), and if so, what would be the parameter to identify the event calendar? Or do I have to resort to manually doing some string manipulations with the URL?



    P.S. In case it helps, I added the events calendar to the nav menu as a Custom Link in Appearance > Menus in the admin panel. It did not appear as a Page or in Events for me there, so I went the Custom Link route.

    • This topic was modified 6 months, 2 weeks ago by BrianCS.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to Identify Nav Menu Item for Events Calendar Page?’ is closed to new replies.