Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Matheson theme use custom header for the blog page.
- function new_header_images() {
- $custom_image = get_post_meta( get_the_ID(), 'matheson_custom_image', true ) ;
- $blog_image = get_post_meta( get_option('page_for_posts'), 'matheson_custom_image', true );
- if ( (is_page() OR is_attachment()) && ( ! empty( $custom_image )) ) {
- // pages and attachements get the custom header image set for that page
- if ( $custom_image )
- echo '<img src="' . esc_url( $custom_image ) . '" alt="" class="header-img" />';
- else
- // or the post thumbnail
- the_post_thumbnail( 'full', array( 'class' => 'header-img' ) );
- } elseif (is_home()){
- // if we are on the home page (the blog page) get the custom header image set for that page
- echo '<img src="' . esc_url( $blog_image ) . '" alt="" class="header-img" />';
- }
- elseif (is_single() && ($custom_image) )
- // if we are on a single blog item then get the custom header image
- {
- echo '<img src="' . esc_url( $custom_image ) . '" alt="" class="header-img" />';
- }
- elseif (is_single() && (! $custom_image) )
- // if on a single blog item and there is no custom header set, then get the image set on the blog page (home)
- {
- if ($blog_image) {
- echo '<img src="' . esc_url( $blog_image ) . '" alt="" class="header-img" />';}
- }
- else {
- $header_image = get_header_image();
- if ( ! empty( $header_image ) ) {
- ?>
- <img class="header-img" src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />
- <?php
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement