- This topic has 7 replies, 3 voices, and was last updated 6 years, 4 months ago by Leo.
-
AuthorPosts
-
December 15, 2017 at 8:28 pm #450617Marty
I created a custom site header for desktop and iPad using the excellent instructions in this forum post:
Change Site Header and Title – based on page
Is it possible to change the mobile site header as well for individual pages? I need to change out the site logo on one page of a client’s site. The desktop version is black-on-white. The mobile version of the logo is white-on-black, so we need to use two different versions of the logo.
Thank you in advance for your help.
December 15, 2017 at 11:02 pm #450652TomLead DeveloperLead DeveloperHi there,
I’m not too sure what you mean – currently everything looks great?
Is there a specific page I should be looking at?
December 16, 2017 at 8:36 am #450917MartyHi, Tom,
Thank you for the prompt reply.
The page you saw should be the correct one. I need a separate mobile NDB logo to display on that page as well when the viewport is mobile sized. Currently, the Add. logo displays and that’s not what my client wants.
Is there some additional code I need to add to this to make that work? This snippet worked great.
<?php global $post; $image = get_post_meta($post->ID, 'custom_header', true); if ( ! empty( $image ) ) : ?> <img src="<?php echo $image; ?>" alt="" /> <?php else : ?> <img src="URL TO MY DEFAULT LOGO" alt="" /> <?php endif; ?>
Thanks!
December 16, 2017 at 9:31 am #450951TomLead DeveloperLead DeveloperYou can switch out the mobile header logo using a filter and conditions like this: https://docs.generatepress.com/article/generate_mobile_header_logo/
Let me know if that helps or not 🙂
December 16, 2017 at 11:51 am #451003MartyThanks, Tom. It’s not a category/archive page, though. It’s a regular old page being used as a category. How would I modify the filter for a single page? Thanks again, sir.
December 16, 2017 at 12:16 pm #451016LeoStaffCustomer SupportHi there,
Something like this should help: https://docs.generatepress.com/article/using-hooks-conditional-tags/#static-pages
Click See more info on A PAGE Page to see examples on targeting a specific page.
December 21, 2017 at 6:36 am #454503MartyTom, Leo, thank you for your help. I added the filter to the functions.php file. I modified the code a tiny bit from the generate_mobile_header_logo documentation, changing is_category to is_page. For others with this need, here is my revised snippet:
// Add custom page mobile logo add_filter( 'generate_mobile_header_logo','lh_category_mobile_header_logo' ); function lh_category_mobile_header_logo( $logo ) { // Return our single page logo URL if ( is_page( 64597 ) ) { return 'https://www.YOUR-URL-HERE.com/wp-content/uploads/2017/9/mobile-header-0915-200x62.png'; } // Otherwise, return our default logo return $logo; } // end filter
Thanks again for your help.
December 21, 2017 at 8:30 am #454641LeoStaffCustomer SupportGlad we could help!
-
AuthorPosts
- You must be logged in to reply to this topic.