Sunday, 25 August 2013

Highlight main menu when on specific posts or pages

Highlight main menu when on specific posts or pages

I am using Genesis and have written a custom function which works fine,
but is very ugly and includes a css statement. The object is to highlight
a menu link in the main header menu when on certain pages or posts.
This function does not work if I remove the css from the function or if I
remove "#header #nav #menu-item-133 a" from the stylesheet. It has to have
both, so something is not right even though it does do the job!
Can anyone correct my error(s)? Thanks.
function blog_link_genesis() {
if( is_single() || in_category('investors') || is_page( array(4, 30))) {
$current = '#header #nav #menu-item-133 a'; }
?>
<style type="text/css">
<?php echo $current; ?> { color: #ff0;}
</style>
<?php }
add_action( 'genesis_header' , 'blog_link_genesis' );

No comments:

Post a Comment