- This topic has 5 replies, 2 voices, and was last updated 10 years, 3 months ago by
Tom.
-
AuthorPosts
-
December 6, 2015 at 9:30 pm #158426
cgu_outreach
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 headerwhere 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.
December 6, 2015 at 10:41 pm #158431Tom
Lead DeveloperLead DeveloperWhich 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.
December 7, 2015 at 8:08 am #158530cgu_outreach
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; ?>December 7, 2015 at 9:07 am #158550Tom
Lead DeveloperLead DeveloperTry 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; ?>December 7, 2015 at 2:27 pm #158613cgu_outreach
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 🙂
December 7, 2015 at 2:39 pm #158619Tom
Lead DeveloperLead DeveloperNo problem! Glad you got it to work! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.