brandwall
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Fixing WordPress
In reply to: Why does Blog become current_page_parent with Custom Post Type?ok Thanks so much for responding. I think I just found a fix for it by putting this code into the functions.php and changing afew items. For my case I have two custom post types ‘motion’ ‘still’.
here is some code I found…
// As of WP 3.1.1 addition of classes for css styling to parents of custom post types doesn't exist. // We want the correct classes added to the correct custom post type parent in the wp-nav-menu for css styling and highlighting, so we're modifying each individually... // The id of each link is required for each one you want to modify // Place this in your WordPress functions.php file function remove_parent_classes($class) { // check for current page classes, return false if they exist. return ($class == 'current_page_item' || $class == 'current_page_parent' || $class == 'current_page_ancestor' || $class == 'current-menu-item') ? FALSE : TRUE; } function add_class_to_wp_nav_menu($classes) { switch (get_post_type()) { case 'motion': // we're viewing a custom post type, so remove the 'current_page_xxx and current-menu-item' from all menu items. $classes = array_filter($classes, "remove_parent_classes"); // add the current page class to a specific menu item (replace ###). if (in_array('menu-item-592', $classes)) { $classes[] = 'current_page_parent'; } break; case 'still': // we're viewing a custom post type, so remove the 'current_page_xxx and current-menu-item' from all menu items. $classes = array_filter($classes, "remove_parent_classes"); // add the current page class to a specific menu item (replace ###). if (in_array('menu-item-348', $classes)) { $classes[] = 'current_page_parent'; } break; // add more cases if necessary and/or a default } return $classes; } add_filter('nav_menu_css_class', 'add_class_to_wp_nav_menu');
Forum: Fixing WordPress
In reply to: Why does Blog become current_page_parent with Custom Post Type?Piet, I am having the same problem, I’ve read a lot about fixes but I haven’t quite figured it out. Could someone please give us some insight? Any help will be greatly appreciated! Thanks!
Viewing 2 replies - 1 through 2 (of 2 total)