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.

So I have created my own template that has a set header for all of my pages home (which is a static front page), about, services, contact, etc....

I have recently created two newer pages products and blog. Products is using CataBlog to list my products and their information so I don't want the same header that I have used on the content pages. This also holds true for the blog page.

I went into my header.php file and did the following:

            <?php

            if (is_page('blog')) { ?>
                <div id="header">
                    <h1>hi</h1>

        <?php
            }

            if (is_page('product')) { ?>
                <div id="header">
                    <h1>hi</h1>

        <?php
            }

            else {?>
                <div id="header">
                    <div id="slider">
                        <ul>                
                            <li><img src="<?php bloginfo('stylesheet_directory') ?>/images/01.jpg" alt="Pawtucket Pawnbrokers" /></li>
                            <li><img src="<?php bloginfo('stylesheet_directory') ?>/images/02.jpg" alt="We Buy Gold" /></li>
                            <li><img src="<?php bloginfo('stylesheet_directory') ?>/images/03.jpg" alt="Need Cash?" /></li>
                            <li><img src="<?php bloginfo('stylesheet_directory') ?>/images/04.jpg" alt="Instant Cash Loans" /></li>     
                        </ul>


                    </div>
        <?php
            }

        ?>

Now, when I go to the blog page the header maintains that of the static pages however the header on the product page is changed to display "hi" as expected. I changed the name blog in the is_page function to another of the static pages and received the desired result. I am assuming this means somewhere in my template files that original header is being called to display on the blog page. If this is true where should I look to make that change? If this is not the case what am I doing wrong?

Any help is always appreciated!

share|improve this question

1 Answer 1

up vote 0 down vote accepted

If the conditional works when using is_page( 'products' ), but does not work when using is_page( 'blog' ), then that means that WordPress isn't finding a static page with the slug blog. First thing to do: verify your slug name.

A second alternative is that the static page blog is using a custom page template, and that the custom page template is calling a different header file, resulting in the above code never getting executed. Are you using a custom page template for the static page blog? If so, you'll need to look at the custom page template file.

Edit

From your comment below:

i forgot to mention that as home is set as my static page in the admin panel the blog page is set as my blog page.

There's your answer. I should have picked up on it, but somehow didn't. Take a look at the Template Hierarchy. You're using the static page blog as your Blog Posts Index, Instead of using is_page( 'blog' ), you need to be using is_home(), which returns true when displaying the Blog Posts Index.

share|improve this answer
    
i forgot to mention that as home is set as my static page in the admin panel the blog page is set as my blog page. I do not have a blog.php template file only the index.php file /products and /blog both work as pages but the blog doesn't contain the custom header –  Marques Feb 23 '12 at 19:49
    
There's your problem! See updated answer. –  Chip Bennett Feb 23 '12 at 19:56
    
wow great thanks! I will definitely look over the template hierarchy and continue learning but im making strides! –  Marques Feb 23 '12 at 20:05

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.