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'm making a site that uses the same header.php for all pages except the blog/home.php. For this, I've created blog-header.php and am attempting to call it using the following:

<?php if( is_page(15) ) { echo get_template_part( 'blog', 'header' );} else { echo get_header(); } ?>

However, it doesn't seem to be working. Any ideas on why that may be? (It should be noted that this is my first attempt at anything like this, and what I have has been pieced together from various forum posts and tutorials.)

blog-header.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 -->

(Unfortunately, the site isn't live yet otherwise I'd provide a link.)

share|improve this question
add comment

1 Answer

Renaming the file header-bog.php and using <?php get_header( 'blog');?> works perfectly.

share|improve this answer
add comment

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.