Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've made a custom header-blog.php(for blog page/home.php) in addition to header.php, both of which use the exact same <nav> code. On the pages that use header.php, the navigation works perfectly. However, on the blog page(home.php), which uses header-blog.php, the navigation doesn't work- all links lead to "Nothing found."

What could be the cause of this? How can I fix it? This is my first time with something like this, so any insight and ideas are greatly appreciated.

header-blog.php

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <meta name="generator" content="Wordpress <?php bloginfo('version'); ?>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
    <link rel="pingback" href="<?php bloginfo('pingback url'); ?>" />
    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" />
    <link rel="shortcut icon" href="<?php bloginfo('template_directory'); ?>/img/favicon.ico" />
    <?php wp_head(); ?>
</head>



<body>
    <div id="blog-header">
        <div class="logo">
            <a href="<?php bloginfo('url'); ?>"><img src="<?php echo get_template_directory_uri(); ?>/img/logo.png" alt="Urban Palate logo" id="logo" /></a>
        </div><!-- end logo -->
        <nav>
            <ul>
                <li><a href="?page_id=7"><img src="<?php echo get_template_directory_uri(); ?>/img/about.png" alt="Urban Palate intro" /></a></li>
                <li><a href="?page_id=12"><img src="<?php echo get_template_directory_uri(); ?>/img/portfolio.png" alt="Urban Palate portfolio" /></a></li>
                <li><a href="?page_id=15"><img src="<?php echo get_template_directory_uri(); ?>/img/blog.png" alt="Urban Palate blog" /></a></li>
                <li><a href="?page_id=10"><img src="<?php echo get_template_directory_uri(); ?>/img/contact.png" alt="Urban Palate contact" /></a></li>
            </ul>
        </nav>
    </div><!-- end blog-header -->
share|improve this question
1  
What does the url look like that is not found VS the url that it should be pointing to? –  Ben Sep 27 '12 at 18:41
    
This appears in the address bar: urbanpalate.com/blog/?page_id=12 After clicking this link: <li><a href="?page_id=12"><img src="<?php echo get_template_directory_uri(); ?>/img/portfolio.png" alt="Urban Palate portfolio" /></a></li> –  user1255049 Sep 27 '12 at 22:15
    
@Ben any ideas? –  user1255049 Sep 28 '12 at 13:52

1 Answer 1

up vote 1 down vote accepted

Well, I'm mostly thinking that you should maybe switch to using wp_nav_menu() for your navigation menus, and CSS to add the images to your nav items, because it's a lot more dynamic that way, and you can use "pretty" permalinks like http://urbanpalate.com/portfolio/some-work.

As it stands though, I think your nav menu items just need a / at the beginning of the urls like this:

<a href="/?page_id=12"><img src="<?php echo get_template_directory_uri(); ?>/img/portfolio.png" alt="Urban Palate portfolio" /></a></li>

That would take you to http://urbanpalate.com/?page_id=12, which I hope would load your portfolio page. The / means it's an absolute url: or, start at your home url, and go to a page. Without the /, your nav items are pointing to pages under the blog page because they are relative to which page you are on.

share|improve this answer
    
Perfect, thank you for your time and efforts. I'll look in to making the switch to wp_nav_menu(). –  user1255049 Sep 28 '12 at 18:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.