Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Update I realized that if an individual blog post doesn't have a featured image or custom header, then it will default to the main header, I wanted it to default to the header that is set on the blog page (from above).
- This sets individual posts to have the same header as the blog page, but only IF there is no custom header or featured image for that page. If there is a featured image it will use that and then look for custom header and then look for custom header on the blog page.
- Here's the function to replace header_images():
- function 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 )) ) {
- if ( $custom_image )
- echo '<img src="' . esc_url( $custom_image ) . '" alt="" class="header-img" />';
- else
- the_post_thumbnail( 'full', array( 'class' => 'header-img' ) );
- } elseif (is_home()){
- echo '<img src="' . esc_url( $blog_image ) . '" alt="" class="header-img" />';
- }
- elseif (is_single() && ($custom_image) )
- {
- echo '<img src="' . esc_url( $custom_image ) . '" alt="" class="header-img" />';
- }
- elseif (is_single() && (! $custom_image) )
- {
- 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
- }
- }
- }
- Edited because of problems when the featured image is set.
- (Its still a hack to the parent theme.)
- Cheers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement