- This topic has 23 replies, 2 voices, and was last updated 9 years, 3 months ago by Tom.
-
AuthorPosts
-
November 25, 2014 at 4:05 am #48992Maike
Hi Tom,
I’m absolutely a newbie in working with wordpress and GeneratePress!
I hope you can help me… π
My problem is, I like to have on each page an individual header image, is this possible –
I hope so! I can’t find a plugin which solves my problem.Thanks in advance!
Greetings, Maike
November 25, 2014 at 11:03 am #49054TomLead DeveloperLead DeveloperHi there,
Do you want it in the header area, where your logo is?
If that’s the case, you’ll have to use hooks with some PHP conditionals.
However, if you want the image to appear above the content/below the navigation, you can use Featured Images (http://en.support.wordpress.com/featured-images/) or our Page Header add-on.
Let me know.
November 25, 2014 at 11:25 am #49061MaikeHi,
thanks for your quick answer!I would like to have it in the area where the logo is.
Can you give me an example?November 26, 2014 at 10:50 am #49283MaikeHi Tom,
today I’ve tried everything, but unfortunately I can’t find a solution for my header-problem…
can you tell me, how I can use these hooks π I told you I’m a newbie πNovember 26, 2014 at 12:31 pm #49318TomLead DeveloperLead DeveloperHi there – sorry for not getting back to you sooner!
Ok, here we go.
First, we need to remove the default header, so go to “Appearance > Customizer > Header Content”, hide the title and tagline, and remove the logo.
Now, go to “Appearance > GP Hooks > Before Header Content”.
This is where we will add our code.
We’ll be using PHP conditionals, using the ones WordPress provides: http://codex.wordpress.org/Conditional_Tags
If we want to specify a page, we would use these conditionals: http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page
So, here’s some example code.
<?php if ( is_page( 'about-page-slug' ) ) { ?> <img src="URL TO YOUR HEADER FOR THIS PAGE" alt="" /> <?php } elseif ( is_page( 'another-page-slug' ) ) { ?> <img src="URL TO YOUR HEADER FOR THIS PAGE" alt="" /> <?php } elseif ( is_page( 'one-more-example' ) ) { ?> <img src="URL TO YOUR HEADER FOR THIS PAGE" alt="" /> <?php } else { ?> <img src="URL TO YOUR HEADER FOR ALL OTHER PAGES" alt="" /> <?php } ?>
So if we break down the code above..
If is page: yoururl.com/about-page-slug, show image for this page.
Else if is page: yoururl.com/another-page-slug, show this image
Else if is page: yoururl.com/one-more-example, show this image
Else if all other pages, show this image.
Be sure to check “Execute PHP” inside the hook, and then save.
Let me know if this makes sense or not π
November 27, 2014 at 7:39 am #49535MaikeThank you so much! I’m happy….it works π
November 27, 2014 at 2:37 pm #49572TomLead DeveloperLead DeveloperAwesome π
December 4, 2014 at 7:15 am #51216MaikeHi Tom,
I’m again-sorry… today I have changed my blog page from a simple page in a contribution page and now my problem is, that the header from the blog page isn’t displayed.
When I click the button “last contributions” on the front page everything is ok. But when I click static page “home” and contribution page “blog” I see the header for all pages on my blog page -grrr π
Do you have a solution?
Thanks in advance!Maike
December 4, 2014 at 9:36 am #51223TomLead DeveloperLead DeveloperAh, that last line needs to change.
Here’s the updated code:
<?php if ( is_page( 'about-page-slug' ) ) { ?> <img src="URL TO YOUR HEADER FOR THIS PAGE" alt="" /> <?php } elseif ( is_page( 'another-page-slug' ) ) { ?> <img src="URL TO YOUR HEADER FOR THIS PAGE" alt="" /> <?php } elseif ( is_page( 'one-more-example' ) ) { ?> <img src="URL TO YOUR HEADER FOR THIS PAGE" alt="" /> <?php } elseif ( is_page() ) { ?> <img src="URL TO YOUR HEADER FOR ALL OTHER PAGES" alt="" /> <?php } ?>
December 4, 2014 at 2:33 pm #51305Maikethanks for your help!! π
April 14, 2015 at 2:33 am #98419villeHi!
Code works fine and I got individual header images but somehow for me it adds some space between header image and menu bar. Any solution for that?
April 14, 2015 at 3:14 pm #98564TomLead DeveloperLead DeveloperCan you link me to the page so I can check out the code?
Thanks!
April 15, 2015 at 7:01 am #98715villeoh, sorry! forgot the address: http://www.jurassicrock.fi/site/
“piknik” has different header image but both have that extra space. header widget don’t do the difference
April 15, 2015 at 7:45 am #98734TomLead DeveloperLead DeveloperAha – this CSS will work:
.inside-header img { position: relative; vertical-align: bottom; }
GeneratePress usually does this for you, but only when the header image is inside the .site-logo element.
April 15, 2015 at 9:54 pm #98899villeThanks! Worked out perfectly!!!
-
AuthorPosts
- You must be logged in to reply to this topic.