Archived topic
Multiple blog header images
4 replies · Started by Chris on April 15, 2017
Hi Tom,
I have an interesting one for you I think. I'm using the events calendar to display 'performances' and have added the following snippet to get the blog header image to display on events calendar archive pages and the main blog page:
add_filter( 'generate_get_blog_page_header','tu_performances_blog_page_header' );
function tu_performances_blog_page_header(){
if ( tribe_is_event_query() && !is_single()) {
return true;
}
if (is_home()){
return true;
}
return false;
}
What I would like to be able to do is specify a different image for each situation - one for the events archives and one for the main blog page. Any idea how i'd go about that?
Thanks!
Chris
As an addiitonal question, I'd also like to do this with the site logo - any ideas?
Hi Chris,
Currently it's not possible with the page header add-on, although it will be in the future.
If it's just an image, you could use the After Header hook in GP Hooks instead:
<?php if ( tribe_is_event_query() && ! is_single() ) { ?>
<img src="IMAGE URL" alt="" />
<?php } ?>
<?php if ( is_home() ) { ?>
<img src="BLOG IMAGE URL" alt="" />
<?php } ?>
For the site logo, there's a filter you can use: https://docs.generatepress.com/article/generate_logo/
Let me know if you need more info :)
Hi Tom,
Thanks for the quick response!
The filter for the logo is working beautifuly - thanks for that. Also found the one to alter the logo href which is also v useful!
You suggestion for the header image put me onto the right track. Your code added an image above the generatepress header. The following does what I needed in that it alters the image that generatepress header uses for the background:
<?php if ( tribe_is_event_query() && ! is_single() ) { ?>
<style>.generate-content-header {
background-image: url(IMAGE_URL);
background-size: cover;
}</style>
<?php } ?>
<?php if ( is_home() ) { ?>
<style>.generate-content-header {
background-image: url(IMAGE_URL);
background-size: cover;
}</style>
<?php } ?>
Thanks for yoru help - great support as ever!
Chris
Perfect! Glad I could help :)