AJDesigns

Matheson theme use custom header for the blog page.

Jun 5th, 2014
244
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Matheson theme use custom header for the blog page.
  2. function new_header_images() {
  3.     $custom_image =  get_post_meta( get_the_ID(), 'matheson_custom_image', true ) ;
  4.     $blog_image = get_post_meta( get_option('page_for_posts'), 'matheson_custom_image', true );
  5.  
  6.     if ( (is_page() OR is_attachment()) && ( ! empty( $custom_image )) ) {
  7.         // pages and attachements get the custom header image set for that page
  8.         if ( $custom_image )
  9.             echo '<img src="' . esc_url( $custom_image ) . '" alt="" class="header-img" />';
  10.         else
  11.         // or the post thumbnail
  12.             the_post_thumbnail( 'full', array( 'class' => 'header-img' ) );
  13.     } elseif (is_home()){
  14.     // if we are on the home page (the blog page) get the custom header image set for that page
  15.      echo '<img src="' . esc_url( $blog_image ) . '" alt="" class="header-img" />';
  16.     }
  17.    
  18.     elseif (is_single() && ($custom_image) )
  19.     // if we are on a single blog item then get the custom header image
  20.     {
  21.         echo '<img src="' . esc_url( $custom_image ) . '" alt="" class="header-img" />';
  22.         }
  23.        
  24.     elseif (is_single() && (! $custom_image) )
  25.     // if on a single blog item and there is no custom header set, then get the image set on the blog page (home)
  26.    
  27.     {
  28.         if ($blog_image) {
  29.         echo '<img src="' . esc_url( $blog_image ) . '" alt="" class="header-img" />';}
  30.        
  31.     }
  32.    
  33.     else  {
  34.         $header_image = get_header_image();
  35.         if ( ! empty( $header_image ) ) {
  36.             ?>
  37.             <img class="header-img" src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />
  38.             <?php
  39.         }
  40.     }
  41. }
RAW Paste Data