Hightlighting current link in menus – with categories and pages
-
Hello!
I’m trying to get this menu to work on my custom theme:
The menu links are hardcoded into the header.php template. As you can see I use ‘Home’ one page and four categories. Here’s the code I have tried to use:
-
<?php if(is_home() && !is_paged()){ ?>
- " title="Click for Home">Home
-
<a <?php
if (is_category('Photography') || in_category('27') && !is_single())
{
echo " class="current"";
}?> href="<?php bloginfo('url') ?>/category/photography">Photography -
<a <?php
if (is_category('The Interweb') || in_category('25') && !is_single())
{
echo " class="current"";
}?> href="<?php bloginfo('url') ?>/category/the-interweb">The Interweb -
<a <?php
if (is_category('Motorsport') || in_category('24') && !is_single())
{
echo " class="current"";
}?> href="<?php bloginfo('url') ?>/category/motorsport">Motorsport -
<a <?php
if (is_category('Everything Else') || in_category('28') && !is_single())
{
echo " class="current"";
}?> href="<?php bloginfo('url') ?>/category/everything-else">Everything Else -
<a <?php
if (is_page('Contact'))
{
echo " class="current"";
}?> href="<?php bloginfo('url') ?>/contact">Contact
<!-- li>
" title="You are Home">Blog Navigation
</li -->
<?php } else { ?><?php } ?>
Issue 1:
When on the homepage the ‘Motorsport’ link is highlighted.Issue 2:
When on the contact page the ‘Everything Else’ link is highlighted.Issue 3:
If you click though to a single post the menu loses it’s highlighting.Has anyone tried something like this before? or do you have any ideas how I can make this work???
Looking forward to hear your response…
Cheers,
Rich -
You did not specify a blog address or reason for posting when you created this topic.
This support forum is for WordPress.com hosted blogs only. If you have a self-hosted WordPress blog you need to seek help at the WordPress.org forums, not here.
If you don’t understand the difference, you may find this information helpful.
- The topic ‘Hightlighting current link in menus – with categories and pages’ is closed to new replies.