0

I have a calendar called Event Organizer that I have been customizing: http://joshrodg.com/open/calendar/. You'll notice if you click on one of the blue events you are redirected to a page that looks like: http://joshrodg.com/open/calendar/event/pastor-bible-study/.

Right now, when someone goes to that page nothing in the navigation bar is highlighted, but I'd like the navigation item Calendar to be highlighted. I am using wp_list_pages to create my navigation.

I think I've seen something like this before, but I'm not sure what I'm after. Basically, the child page of the the Calendar page would highlight the main page Calendar in the navigation bar when you are on that page.

I thought that would involve styling li.current_page_ancestor, but that doesn't seem to do anything.

I don't know if it's easier to add this functionality for all child pages for any main navigation item (i.e. Home, About, Ministries, Calendar, Location, Contact), but that would work to.

Anyone have any ideas?

Thanks, Josh

5
  • Your events aren't actually child pages, they're a separate custom post type. You could probably target that menu item on event pages if you used body_class for the body tag to identify when you're viewing an event.
    – Milo
    Nov 28, 2016 at 3:39
  • Hey there, thanks for letting me know that they are custom post types...that definitely helps! I installed this plugin: wordpress.org/plugins/custom-post-type-parents which works, just trying to figure out the logic behind it. Nov 28, 2016 at 3:55
  • @milo, this is something that would work, but it's too specific. I would have to know the ID of the page in the menu. If I applied this theme to another WordPress install, I would need to go in and tweak the CSS in order for everything to work properly. The plugin is a better solution because I just activate it and I don't have to change anything in the theme...although, I was hoping for a function or something, which would be 10 times better than a plugin. Nov 29, 2016 at 13:06
  • You can do it with a custom walker like in this answer, I imagine that's what the plugin uses.
    – Milo
    Nov 29, 2016 at 16:23
  • Thanks @Milo! I'm definitely looking into this one, still trying to understand how to implement the custom walker :-) Dec 22, 2016 at 13:54

1 Answer 1

0

So, I never did figure out how to do this without the plugin I mentioned. What fixed the issue was installing: wordpress.org/plugins/custom-post-type-parents. This plugin has a Settings page which allows you to choose the page that is the parent for your custom post type, then it adds the classes necessary to the wp_list_pages menu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.