Advertisement
alchymyth

custom header on 'page for posts' page

May 28th, 2012
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1.                 <?php
  2.                     // The header image
  3.                     // Check if this is a post or page, if it has a thumbnail, and if it's a big one
  4. if( get_option( 'page_for_posts' ) ) $the_id = get_option( 'page_for_posts' );
  5. if( is_singular() ) $the_id = $post->ID;
  6.                 if ( (is_singular() || get_option( 'page_for_posts' )) &&
  7.                             has_post_thumbnail( $the_id ) &&
  8.                             ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $the_id ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) ) ) &&
  9.                             $image[1] >= HEADER_IMAGE_WIDTH ) :
  10.                         // Houston, we have a new header image!
  11.                         echo get_the_post_thumbnail( $the_id, 'post-thumbnail' );
  12.                     else : ?>
  13.                     <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
  14.                 <?php endif; // end check for featured image or standard header ?>
  15.             </a>
  16.             <?php endif; // end check for removed header image ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement