Different headers on each page
-
Hello, I’m looking for a script to add on my blog that could load a different image on the header according to the page.
*Example: if you are on the “About” page load this.jpg image.
Thanks!!
-
Read this in the codex. It will do exactly what you want:
https://codex.www.ads-software.com/Conditional_TagsWow… I got lost.
Where do I have to implement this code, in the header.php ?Wherever you have your banners that you want swapped out. Those are usually in the header.php file.
Am I right to assume that you would use the following example in header.php:
is_page_template(‘home.php’)
is_page_template(‘about.php’)
is_page_template(‘history.php’)
is_page_template(‘products.php’)I am not sure I get it.
Please help.
ThanksAlmost! I think
is_page()
is the one you want. So for the example you provided, if the image you wanted to load was “about.jpg” then you would write:if(is_page('About')){ echo '<img src="the-path-to-your-image/about.jpg" />'; }
You’ll have to replace “the-path-to-your-image” with the actual path to your image. For different pages, just replace “About” with the title of your page. For example:
is_page('Contact Us')
That should do it.
Thanks. What if I am trying to call swf files?
Best,
savantcreativeI don’t work with Flash much, but I looked it up real quick and it looks like this should work:
<object width="550" height="400"> <param name="movie" value="somefilename.swf"> <embed src="somefilename.swf" width="550" height="400"> </embed> </object>
You’ll have to adjust the height, width, and filename, but that should be all.
You have to embed the SWF object into the header.php. Make sure your swf dimensions match with your CSS… #header { width: 550px; height: 400px; }
My question regarding different headers is the following… I’m using different swf files for each category. So, will it work sort of the same as the .jpg method you mentioned?
if(is_page(‘About’)){
echo ‘<<object width=”800″ height=”460″>
<param name=”movie” value=”somefilename.swf”>
<embed src=”somefilename.swf” width=”800″ height=”460″>
</embed>
</object> />’;
}Any suggestions?
Yes, that should work. However, you’ve got a couple extra characters there. You’ll need to remove the
<
at the beginning of the echo and the/>
at the end. Something like this:if(is_page('About')){ echo '<object width="800" height="460"> <param name="movie" value="somefilename.swf"> <embed src="somefilename.swf" width="800" height="460"> </embed> </object>'; }
I am trying to do the same thing, but my header has rotating images. I was able to create a new template called himalayas.php (instead of index.php), but don’t know how to direct this to the new image folder called himalaya_images (which holds the new images I want to rotate through the new header.)
I assume I need to create a new header.php, but there is also a bfa_header_config.php and bfa_rotating_header_images.php. in the functions folder. Wouldn’t I need to create new versions of those as well?
I do not understand php at all, so you can see it is getting very confusing.
Ok… this thing is not working! I have written the following code on the header.php (under the div id=”header”).
<div id=”header”>
if(is_page(‘About’)){
echo ‘<object width=”800″ height=”460″>
<param name=”movie” value=”somefilename.swf”>
<embed src=”somefilename.swf” width=”800″ height=”460″>
</embed>
</object>’;
}
else(is_page(‘Contact’)){
echo ‘<object width=”800″ height=”460″>
<param name=”movie” value=”somefilename.swf”>
<embed src=”somefilename.swf” width=”800″ height=”460″>
</embed>
</object>’;
}
</div>All right… IT WORKS!!! I was missing the php tags… to all of you that would like to implement different swf headers depending on your category (About, Contact etc). here it is:
1. Open your header.php file
2. Under the div id line that says <div id=”header”> write the following code…
<?php
if(is_page(‘Contact’)){
echo ‘<object width=”800″ height=”460″>
<param name=”movie” value=”somefilename.swf”>
<embed src=”somefilename.swf” width=”800″ height=”460″>
</embed>
</object>’;
} ?>
<?php
else(is_page(‘About’)){
echo ‘<object width=”800″ height=”460″>
<param name=”movie” value=”somefilename.swf”>
<embed src=”somefilename.swf” width=”800″ height=”460″>
</embed>
</object>’;
} ?>*This example assumes that you had created 2 categories (or pages) with the name “Contact” and “About”. If you have more than two headers… replace the condition “else” with “else if” and keep adding different headers. However the last condition should be “else”.
Thanks to all of your help!!!
Hi there,
I came across this post a few weeks ago, and it almost works perfect with flash instead of an image. I’ve got drop down navigation menus positioned above the flash, which are hidden behind the flash in IE7 and FF 3.0.12 on a PC – all works perfectly on a Mac using Safari 4.0.2 and FF 3.0.12.I know the problem is because Flash will always display on top of dynamic layers (https://kb2.adobe.com/cps/155/tn_15523.html) and there’s a fix sometimes using the W Mode parameter, as I got it working before on a similar project.
If anyone has any ideas on implementing the W Mode parameter with the code below, I would love to hear back.
Many thanks everyone.
<div id=”header” class=”clearfix”>
<?php if(is_page(‘About Us’)){
echo ‘<object width=”960″ height=”440″ >
<param name=”movie” value=”somefilename.swf”>
<embed src=”somefilename.swf” width=”960″ height=”440″>
</embed>
</object>’;
}
else if(is_page(‘Services’)){
echo ‘<object width=”960″ height=”440″>
<param name=”movie” value=”somefilename.swf”>
<embed src=”somefilename.swf” width=”960″ height=”440″>
</embed>
</object>’;
}You can use the plugin NextGenGallery to rotate Flash Banners throughout the header rather than what you’re currently using.
We have that done on this site:
https://gnoics.org
And it’s a matter of uploading the desired banners to a folder on the server and pointing the header code there. (Take a peek at the source code on the site and you’ll see what I mean.HTH.
- The topic ‘Different headers on each page’ is closed to new replies.