• Hi There,

    for 2 days now I try to set a different picture for the header for a different page. I’ve searched the internet and wordpress forum and I tried everything. Also I’ve installed several plugins that say that can do the Job (dynamic header etc.) but no luck. Also when I try to put in some codes in the header.php my site fails to load or doesn’t load properly. So this is my last option.

    I made my own theme where I cannot access the header in the wordpress admin, also is the header a few pixels from the top. I hope that someone can help me with my problem.

    Thank you, my site is https://www.eriksmans.nl

Viewing 8 replies - 1 through 8 (of 8 total)
  • You could use a custom field on the Page or a Post, upload the header to media and get the URL.

    So the custom field is ‘page-image’ the value is the image URL, then code in the header.php like this to return and set the image url, only if set, if not then return the default.

    You would need to match this to your code(un-tested example).

    <?php if(get_post_meta( $post->ID, 'page-image', true )) : ?>
       <?php $imgpath = get_post_meta( $post->ID, 'page-image', true ); ?>
       <img src="<?php echo $imgpath ?>" alt="Default Alt Text Here" />
    <?php else: ?>
       <!-- Normal Header Image Code -->
    <?php endif; ?>

    HTH

    David

    Thread Starter eriksmans

    (@eriksmans)

    Hi David,

    When I try this I get a blank space on my page where the header should be and underneath my site starts. If you check my website and than contact you see what I mean. Here is my code that I have for my header, hope you can help me.

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Your theme is an Artisteer 2.5 theme, so the code would update, art-header-jpg

    This is in the folder & file /templates/page.php

    Find:

    <div class="art-header">
                    <div class="art-header-jpeg"></div>

    Code something like this should work! (again this is un-tested)

    <div class="art-header">
        <?php if(get_post_meta( $post->ID, 'page-image', true )) : ?>
           <?php $imgpath = get_post_meta( $post->ID, 'page-image', true ); ?>
           <div class="art-header-jpeg" style="background-image: url('<?php echo $imgpath; ?>');">
           </div>
        <?php else: ?>
           <div class="art-header-jpeg"></div>
        <?php endif; ?>

    HTH

    David

    Thread Starter eriksmans

    (@eriksmans)

    Hi David,

    I get the same result, with this code, so on contact a blank space ( where the picture should be ) and than the rest of my website with the standard header…So no luck with that either

    Thanks for the help

    Hi Erik,

    For the minor problem of the banner being a few pixels lower than you would like: I checked with firebug (I hope you are using this indispensable tool!), and found this: line 316 of style.css:
    margin-top: 10px !important;
    I tried changing the 10 to 0 and the banner moved up nicely.

    I’ve got an alternative idea for you to try with your banner. But first — have I understood right? You would like a different banner image on each page? Nothing random? If so, why not insert the image in the admin page for the individual page? The beauty of header.php is that it gives you a consistent banner across all your pages, but that’s not what you want!

    The only thing to be careful with for this approach would be to make sure that your navigation bar gets placed in the right place on the page. Firebug will help with that.

    Hi Number Cruncher, Erik,
    This is an Artisteer theme and the div for the header image is in /templates/page.php.

    I use something like this for a sub header, could you add the page.php code to https://www.wordpress.pastebin.com, and paste the link here:

    Another silly question is you have added a custom field called page-image and added a full url to the page?

    David

    Ok tested and Working, as the header code is in a subfolder we have to declare the post as a global.

    https://digitalraindrops.pastebin.com/mQDVpWL5

    Lines 14 – 22 in the above code.

    HTH

    David

    I think i have a slightly similar problem.. i also created a wordpress theme based on artisteer but my created flash header shows on all pages how can i make it show in the homepage only and not in posts and pages in my wordpress site. It would be a very great help if you guys reply. Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘different header different page’ is closed to new replies.