Timeline for current-menu-item class for custom post type parent
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 13, 2017 at 12:37 | history | edited | CommunityBot |
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
|
|
Nov 5, 2013 at 13:15 | comment | added | Richard Mišenčík | I did now, didnt work. I tried something else tho, basic example from the wp codex for this function. Here it is: function rm_custom_services_class($classes, $item) { if(is_single() && $item->title == "Služby") { $classes[] = "current_page_parent"; } return $classes; } Thats all and it works. Im just wondering if its possible to change $item->title = "Služby" to something like $item->slug == 'sluzby'. In case the page name would change. | |
Nov 5, 2013 at 13:03 | comment | added | Joe | Hummm, if you think the problem might be related to the rewrite have you tried not rewriting the cpt? Just to confirm the child pages are set as 'Sub menu items' in the menu | |
Nov 5, 2013 at 12:50 | comment | added | Richard Mišenčík | Yes, I have created Menu with all the links in it. I think it could be a problem with rewrite since my CPT name is services but my URL for that page is wordpress/sluzby. Im really clueless. Is there anything else I could try? | |
Nov 5, 2013 at 12:40 | comment | added | Joe |
And you have the menu defined in the admin area under Appearance->Menus If you do, and the menu is still not providing the class. This is not a problem I have come across.
|
|
Nov 5, 2013 at 12:29 | comment | added | Richard Mišenčík | This is the code I use: wp_nav_menu(array( 'container' => false, 'container_class' => '', 'menu' => '', 'theme_location' => 'main-nav', 'items_wrap' => '<ul id="menu">%3$s</ul>', 'fallback_cb' => 'rm_main_nav_fallback' )); | |
Nov 5, 2013 at 12:06 | comment | added | Joe | Are you using a custom menu? | |
Nov 5, 2013 at 11:24 | comment | added | Richard Mišenčík | not working for me. Could it be because Im using rewrite and therefore having different name for custom post type and for the page itself? | |
Nov 5, 2013 at 10:24 | history | answered | Joe | CC BY-SA 3.0 |