Archived topic
Separate Blog Page header?
5 replies · Started by cgu_outreach on December 6, 2015
Hi Tom, posted this earlier at the end of a resolved thread by mistake, tried to go back and delete it but I'm too late...
My question:
Just tidying up our site and noticed that the custom header function works great across the whole site except for the blog page. For some reason it defaults to the generic website header and doesn’t provide the option to add a custom header as do the ‘regular’ web pages. The only option I see is from the APPEARANCE >> BLOG PAGE HEADER. That only puts a sub-header down below the main website header like below:
N A V B A R2
Default Custom Header
N A V B A R1
blog header
where I’m trying to get the custom blog header to show where the default custom header is showing
Clear as mud? :)
Sorry for the double post.
Which custom header function are you using?
The Blog is a tough one because WP ignores metabox values on the blog page, which is why we need an “Appearance > Blog Page Header” page vs just using the regular Page Header metabox.
Hi Tom, thanks for the reply.
Here's the php function used in the "Before Header Content" Hook
<?php
global $post;
$image = get_post_meta($post->ID, 'custom_header', true);
if ( ! empty( $image ) ) : ?>
" alt="" style="position: relative; vertical-align: bottom;" />
<?php else : ?>
<?php endif; ?>
Try this:
<?php
global $post;
$image = get_post_meta($post->ID, 'custom_header', true);
if ( ! empty( $image ) ) : ?>
<img src=".." alt="" style="position: relative; vertical-align: bottom;" />
<?php elseif ( is_home() ) : ?>
<img src="URL TO BLOG HEADER" alt="" />
<?php else : ?>
<img src="xxxxxxxxxxxxx" alt="" />
<?php endif; ?>
I had just about got to this stage with the is_home IF statement, but didn't have the syntax correct. Your snippet got it to work perfectly once I got the right img src link in the first IF statement.
" alt="" style="position: relative; vertical-align: bottom;" />
Works like a charm now, thanks. Killer job on going beyond the call of duty with your help on this.
Double 'spro is coming up :)
No problem! Glad you got it to work! :)
