Support » Fixing WordPress » Home showing as both HOME and BLOG

  • I use the following code for my main nav:

    <ol>
    					<?php if (is_home()) { ?>
    						<li class="n-home selected">Home</li>
    					<?php } else { ?>
    						<li class="n-home">
    							<a title="Home" href="<?php bloginfo('url'); ?>/">Home</a>
    						</li>
    					<?php } ?>
    					<?php if (is_page('portfolio') || is_category('portfolio') || in_category('portfolio')) { ?>
    						<li class="n-portfolio selected">Portfolio</li>
    					<?php } else { ?>
    						<li class="n-portfolio">
    							<a title="Portfolio" href="<?php bloginfo('url'); ?>/portfolio">Portfolio</a>
    						</li>
    					<?php } ?>
    					<?php if (is_page('projects')) { ?>
    						<li class="n-projects selected">Projects</li>
    					<?php } else { ?>
    						<li class="n-projects">
    							<del><a title="Projects" href="<?php bloginfo('url'); ?>/projects">Projects</a></del>
    						</li>
    					<?php } ?>
    					<?php if (is_page('downloads')) { ?>
    						<li class="n-downloads selected">Projects</li>
    					<?php } else { ?>
    						<li class="n-downloads">
    							<del><a title="Downloads" href="<?php bloginfo('url'); ?>/downloads">Downloads</a></del>
    						</li>
    					<?php } ?>
    					<?php if (is_page('contact')) { ?>
    						<li class="n-contact selected">Contact</li>
    					<?php } else { ?>
    						<li class="n-contact">
    							<a title="Contact" href="<?php bloginfo('url'); ?>/contact">Contact</a>
    						</li>
    					<?php } ?>
    					<?php if (is_page('about')) { ?>
    						<li class="n-about selected">About</li>
    					<?php } else { ?>
    						<li class="n-about">
    							<a title="About" href="<?php bloginfo('url'); ?>/about">About</a>
    						</li>
    					<?php } ?>
    					<?php if (is_page('blog') || is_category('blog') || in_category('blog')) { ?>
    						<li class="n-blog selected">Blog</li>
    					<?php } else { ?>
    						<li class="n-blog">
    							<a title="Blog" href="<?php bloginfo('url'); ?>/blog">Blog</a>
    						</li>
    					<?php } ?>
    				</ol>

    When I visit my homepage however it treats it as both the Home page and also the Blog page. Any ideas why? I have similar code setup for the <title> tags and they show the correct info based on the page.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I have also tried is_front_page but it still shows up as being the blog page as well as the home page. The only way around this that I can see is to check if NOT the home page, is this possible?

    Now that I think of it the issue will be that blog is the final else statement right? So what WP is doing is saying that blog is selected because its else of all the rest right?

    EDIT: Turns out this isn’t the case, it really is a problem with WP getting confused with is_home and is_page(‘blog’). So that’s where the problem is. Any updates on why this is doing it here but not in the title?

    Found a solution that works:

    <?php if (is_home()) { ?>
    						<li class="n-blog">
    							<a title="Blog">/blog">Blog</a>
    
    					<?php } elseif (is_page('blog') || is_category('blog') || in_category('blog')) { ?>
    						<li class="n-blog selected">Blog
    
    					<?php } else { ?>
    						<li class="n-blog">
    							<a title="Blog">/blog">Blog</a>
    
    					<?php } ?>

    If anyone has any suggestions to improve my solution, please do share. Also I’m not exactly sure why I have had to do this and couldn’t use the code I had previously :/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Home showing as both HOME and BLOG’ is closed to new replies.