Viewing 3 replies - 1 through 3 (of 3 total)
  • Yes.

    Probably the *simplest* way would be to ensure the images you’re using have the same name as the slug of the page you’re loading. So if you had a page called “Dog Drool is Gross”, then the slug (by default) would be “dog-drool-is-gross”. So create an image for that pag and name it “dog-drool-is-gross.jpg” and upload to your theme folder images directory.

    Then, in the header, add in the following where you want the image to appear:

    <?php if(have_posts()) : while(have_posts()) : the_post();
          global $post;
          $pagetitle = $post->post_name; ?>
    <img src="<?php bloginfo(template_directory'); ?>/images/<?php echo $pagetitle; ?>.jpg" alt="" />
    <?php endwhile; endif; rewind_posts(); ?>

    That’s off the top of my head – not tested – but it should work.

    Thread Starter rgracia

    (@rgracia)

    Thank you doodlebee, will give it a try later on today.

    ensure the images you’re using have the same name as the slug of the page

    Nice idea this. It saves storing the image file name in a custom field (or similar). Like it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Different header images for different pages’ is closed to new replies.