Show Different Header for Different Pages in WordPress

16548v2-max-150x150[1] I wanted to choose a different header for my home page and for my internal post pages in WordPress. Objective was to show a particular advertisement in home page and hide it in other page. You can use this code to show different graphics on different pages also.

I used a conditional tag ‘IF’ to solve my problem. Just insert following code in your header.php file.

<?php if(is_home()) {

echo ‘HTML CODE‘;
}?>

In place of HTML CODE just put code to display any graphics that you want to display in home page but not on other pages, and you are done. Check the below the screen shots from www.crazubulb.com. Notice the Yellow rectangle. It shows that home page displays the image ad whereas other pages not.

Note:Don’t remove single quotes HTML CODE. Just replace HTML CODE between single quotes.

Home Page crazybulb screenshot
Other Pages crazybulb screenshot1

You can also use is_page(‘#’) instead of is_home(), if you want to select any particular page, you need to replace # with the page id. If you want more options on conditional tag, you can visit wordpress codex. Please feel free to ask if you have any query regarding this.

Comments are closed.

Follow us on Twitter! Follow us on Twitter!

daily email newsletter

Enter your email address:

Recent Posts

Video of The Day

Blogs Worth Visiting