current_page_item –> on single post, category and archive
-
Hi all,
My thmeme gives me dynamic highligt of the menu-item. Great!
However; I need a function to return some “current” for a menu-item in case a single post, the archive or the category is viewed.
How do I do that?
From the header:
<?php wp_nav_menu(array( 'container' => '', 'theme_location' => 'header-menu') ); ?>
From the functions.php
/** * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. */ function responsive_page_menu_args( $args ) { $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', 'responsive_page_menu_args' ); /** * Remove div from wp_page_menu() and replace with ul. */ function responsive_wp_page_menu ($page_markup) { preg_match('/^<div class=\"([a-z0-9-_]+)\">/i', $page_markup, $matches); $divclass = $matches[1]; $replace = array('<div class="'.$divclass.'">', '</div>'); $new_markup = str_replace($replace, '', $page_markup); $new_markup = preg_replace('/^<ul>/i', '<ul class="'.$divclass.'">', $new_markup); return $new_markup; } add_filter('wp_page_menu', 'responsive_wp_page_menu');
Can I just add something like this:
function test { if (is_single()) { echo " id=\"current-test\""; } }
Do I just add it in the functions? And where do I call it?
I could hardcode the menu, but I really dont want to ??
So – I just need the existing functions, that returns current_page_item, to return current_page_item for single, archive and category.
Thanks.
rasmus
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘current_page_item –> on single post, category and archive’ is closed to new replies.