WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Different headers on each page (21 posts)

  1. pbwordp
    Member
    Posted 4 years ago #

    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!!

  2. Joni
    Member
    Posted 4 years ago #

    Read this in the codex. It will do exactly what you want:
    http://codex.wordpress.org/Conditional_Tags

  3. pbwordp
    Member
    Posted 4 years ago #

    Wow... I got lost.
    Where do I have to implement this code, in the header.php ?

  4. Joni
    Member
    Posted 4 years ago #

    Wherever you have your banners that you want swapped out. Those are usually in the header.php file.

  5. savantcreative
    Member
    Posted 4 years ago #

    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.
    Thanks

  6. Alex Mansfield
    Member
    Posted 4 years ago #

    Almost! 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.

  7. savantcreative
    Member
    Posted 4 years ago #

    Thanks. What if I am trying to call swf files?
    Best,
    savantcreative

  8. Alex Mansfield
    Member
    Posted 4 years ago #

    I 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.

  9. pbwordp
    Member
    Posted 4 years ago #

    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; }

  10. pbwordp
    Member
    Posted 4 years ago #

    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?

  11. Alex Mansfield
    Member
    Posted 4 years ago #

    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>';
    }
  12. SiberianSiren5
    Member
    Posted 4 years ago #

    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.

  13. pbwordp
    Member
    Posted 4 years ago #

    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>

  14. pbwordp
    Member
    Posted 4 years ago #

    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!!!

  15. girdwood
    Member
    Posted 4 years ago #

    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 (http://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>';
    }

  16. Joni
    Member
    Posted 4 years ago #

    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:
    http://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.

  17. davemoppert
    Member
    Posted 4 years ago #

    I followed pbwordp's directions on how to replace the banner with a flash swf file, but its just not happening. There's a big white square where the banner should be.

    Help me out: http://epicgeniusmedia.com

    Do I need to include an AC_RunActiveScript.js file?

    Also, I currently have the swf file located in the root folder of my theme (wp-content>themes>GreenBeige>banner.swf)

    I added the following code into my header.php file:

    <?php
    {
    echo '<object width="800" height="460">
    <param name="movie" value="banner.swf">
    <embed src="banner.swf" width="800" height="460">
    </embed>
    </object>';
    } ?>

    What did I do wrong?

    - Moppert

  18. davemoppert
    Member
    Posted 4 years ago #

    CORRECTION:

    the code is actually:

    <?php
    {
    echo '<object width="900" height="150">
    <param name="movie" value="banner.swf">
    <embed src="banner.swf" width="900" height="150">
    </embed>
    </object>';
    } ?>

  19. the_doctor199
    Member
    Posted 4 years ago #

    Is it possible to have different sized headers on each page? I want a larger one on my homepage than on the rest. Do I have to change the code in the css file? If so, what to?

  20. the_doctor199
    Member
    Posted 4 years ago #

    Sorted!

  21. Gouri
    Member
    Posted 4 years ago #

    My header contains an ad-box in which adsense ads are displayed. I am also using Google custom search. On Search Results page, I want to display the header without ad-box. Is it possible? Here's my blog.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.