Community Forums › Forums › Archived Forums › Design Tips and Tricks › get_header() swap logo on sub pages
Tagged: get_header, header.php, Logo, single.php
- This topic has 3 replies, 2 voices, and was last updated 12 years, 1 month ago by
David Chu.
-
AuthorPosts
-
February 26, 2013 at 5:00 am #22868
stephencounsell
MemberHi
is it possible to change the code that is called by get_header() so that I can add some logic to change the logo on post single pages.
I'm using single.php with get_header() at the top. This pulls in a Logo file and a Menu. On these single pages I need to change the logo only but can't find where the logo is coming from.
my test site URL is:
http://1064727136.1055256391.temp.prositehosting.co.uk
A sub page is:
http://1064727136.1055256391.temp.prositehosting.co.uk/?page_id=26
Thanks for any help.
Steve
February 26, 2013 at 5:07 pm #22999David Chu
ParticipantThat's an intriguing question. I scratched my head for a bit, until I realized that the image is nowhere near the header, so your plan won't work, unfortunately. There's a DIV way down at the bottom of the HTML that's pumping that photo in there, actually below the footer. Take a look with Firebug or the like.
I don't have the Stretch theme, but I can infer a couple things. Somewhere in its admin there may be either a place for "homepage image" or the like. Or else there could be some custom field per page that allows you to upload a giant image background. Check those first.
In some cases like this, if the image was being displayed as a CSS background, I would override the CSS to use another image. Not in this case, as we have a full IMG tag.
I can't see inside to suggest further stuff, but that might get you on the path. Hopefully it's just a matter of something in my second paragraph there. If my ideas don't pan out, you might be in for some examination of the various functions, and maybe look for stuff that indicates sub footer or some similar nomenclature.
Dave
Dave Chu · Custom WordPress Developer – likes collaborating with Designers
February 27, 2013 at 2:21 am #23065stephencounsell
MemberHi flamenco,
Thanks for taking a look at that for me.
The image in a div that you refer to is my attempt at making the change.
I opened up the header.php file and added in a PHP IF statement to echo out a different logo if it was not the home page. Here's my header.php file. This is a copy of the header.php in genesis
<?php do_action( 'genesis_doctype' ); do_action( 'genesis_title' ); do_action( 'genesis_meta' ); wp_head(); /** we need this for plugins **/ ?> </head> <body <?php body_class(); ?>> <?php do_action( 'genesis_before' ); ?> <div id="wrap"> <?php do_action( 'genesis_before_header' ); do_action( 'genesis_header' ); If(is_home()){ echo '<img src="images/logo.png" class="hlogo" />'; } else { echo '<img src="images/logo-alt.png" class="hlogo" />'; } do_action( 'genesis_after_header' ); echo '<div id="inner">'; genesis_structural_wrap( 'inner' );
This problem has made me do A LOT of learning about Genesis but I'm still so confused...
The original logo was a CSS background to the "#header #title" div
I'm sure there is a more elegant solution out there but this is "working?" so I'll go with this for the time being.
Thanks again
Steve
February 27, 2013 at 8:09 am #23085David Chu
ParticipantAh! I totally misunderstood the question. 🙂 You're speaking of the small Peter Twiss image in the header, as opposed to the big background. I actually don't use the CSS background for the header for various reasons, including many requests for headers that traverse the whole width instead of just the "main container wrap".
When I just want to stick the same image for all pages in the header, I'll just do this, which pops it right in that title area (the following examples would just be placed in the functions.php file):
add_action( 'genesis_site_title', 'dc_stick_logo' );
function dc_stick_logo() {
echo '<div id="logoSlot"><a href="/"><img src="'.CHILD_URL.'/images/CLYCD-Logo.jpg" alt="My Site\'s Title" /></a></div>';
}But if I want to put "any" image in the header, there are several ways to do that, too. I could use a custom field, or I could leverage the Featured Image (and some additional markup may need to be added):
add_action('genesis_site_title', 'dc_put_in_featured');
function dc_put_in_featured() {
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
}Or you could use the handy Custom Body Class on your page and do all the rest through CSS. 🙂 Before doing any of these methods, I'll either take out (or ignore) the stock Background setting in admin.
I hope that's helpful. I have gotten so used to the handy Genesis hooks and filters that it's very rare that I edit any Genesis template files anymore. But that's a legit method, too, of course.
Cheers, Dave
Dave Chu · Custom WordPress Developer – likes collaborating with Designers
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.