Skip to content

Instantly share code, notes, and snippets.

@revitalk
Created May 10, 2018 19:58
Show Gist options
  • Save revitalk/3caaf66fee0af5cc0c51210524aad921 to your computer and use it in GitHub Desktop.
Save revitalk/3caaf66fee0af5cc0c51210524aad921 to your computer and use it in GitHub Desktop.
// images should be stored in images folder in root directory. They should be sized to their final size in Photoshop.
<?php
if ( is_home() ) $my_header_image = "Building-2009_0064.jpg"; // for home page
elseif ( is_page('History')) $my_header_image = "AnnualMeet-2009_0095.jpg"; // identifies a page by its title
elseif ( is_page('History') or is_page('Scholarship Programs') ) $my_header_image = "AnnualMeet-2009_0095.jpg"; // assigns an image for two pages at once
elseif ( is_page(2) ) $my_header_image = "http://.../ImageB.png"; // identifies a page or post by its id
else $my_header_image = "Building-2009_0064.jpg"; // for all other pages (default image)
?>
<img src="<?php echo get_template_directory_uri(); ?>/images/<?php echo $my_header_image; ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment