- This topic has 18 replies, 3 voices, and was last updated 3 years, 10 months ago by
Fernando.
-
AuthorPosts
-
July 18, 2022 at 9:30 pm #2286874
Michelle
I’ve implemented several different php codes for this that I found on this forum, but can’t get them to work without a php error.
I have a fixed site logo on all pages. I want a different logo on one page of my site. I will settle for having it on a category if that is easier. How do I do this?
Thanks!
July 18, 2022 at 9:54 pm #2286882Fernando Customer Support
Hi Michelle,
Have you tried this code by David?: https://generatepress.com/forums/topic/change-logo-image-on-one-page/#post-1874727
Kindly let us know.
July 18, 2022 at 10:56 pm #2286928Michelle
Yes, that was the first one I implemented.
July 18, 2022 at 11:34 pm #2286943Fernando Customer Support
Can you try adding the code again, and provide the specific link to the page you’re trying to change the logo of? I’ll check what’s causing it not to work.
July 19, 2022 at 2:35 pm #2287867Michelle
Thank you. I am now working on a staging site until I get it straight. Below are my login credentials. David’s code is in Snippets
July 19, 2022 at 11:01 pm #2288057Fernando Customer Support
Thanks!
Can you try this?:
add_filter( 'generate_logo', function( $logo ) { // Return our category logo URL if ( 6619 === get_the_ID()) { return 'https://cdn.reachingmyworld.com/wp-content/uploads/2022/06/18162522/Daily-Reach-Logo-For-Site.png'; } // Otherwise, return our default logo return $logo; } ); add_filter( 'generate_retina_logo', function( $logo ) { // Return our category logo URL if ( 6619 === get_the_ID()) { return 'https://cdn.reachingmyworld.com/wp-content/uploads/2022/06/18162522/Daily-Reach-Logo-For-Site.png'; } // Otherwise, return our default logo return $logo; } );Kindly let us know how it goes!
July 20, 2022 at 9:07 am #2288709Michelle
I tried it and could not get it to work. I did clear my cache.
As a temporary measure, I added the desired logo as an image and disabled the site logo. This is a “fix it with tape” method, but I’d like to have this work properly with php.
July 20, 2022 at 11:09 am #2288825Ying
StaffCustomer SupportHi Michelle,
Actually, you can use a header element to upload different logo and assign it to specific pages. I don’t think PHP code is necessary.
https://docs.generatepress.com/article/header-element-overview/#site-headerJuly 20, 2022 at 2:19 pm #2288943Michelle
Still needing some help with this. The new logo doesn’t show sticky on tablet or desktop, and still links to the homepage (noooooooo——–)
July 20, 2022 at 3:16 pm #2288957Michelle
How do I continue to style this Element header?
1. Disable replacement logo’s link to the homepage (not the main logo)
2. Sticky on scroll only shows on mobile. I want it to work on tablet and desktop too.July 20, 2022 at 7:03 pm #2289038Fernando Customer Support
Where did you add the custom logo? Is it in the staging site or the the live site? Can you provide the link? Also, where did you add the code above?: https://generatepress.com/forums/topic/replace-my-site-logo-with-a-different-one-on-a-specific-page-or-category/#post-2288057
Kindly let us know.
July 20, 2022 at 7:07 pm #2289039Michelle
I added the code in Snippets, and then used Site Header in Elements, per Ying’s suggestion. Below are my credentials for the Live Site. The staged site was misbehaving…
July 20, 2022 at 8:26 pm #2289068Fernando Customer Support
Would you know why is your menu not showing in the Daily reach page? Did you add a custom code to do as such?
Kindly let us know.
July 20, 2022 at 8:47 pm #2289078Michelle
The Daily Reach logo IS showing up on the Daily Reach page. It just isn’t sticky on desktop like I want it to be, and it still links to the homepage. I want to disable the link.
July 20, 2022 at 10:32 pm #2289130Fernando Customer Support
Let’s try to solve the sticky issue first.
I believe you’ve disabled the Primary Navigation in the Page settings. Doing so would also disable the sticky nav.
You’ll need to enable it to have the stick header on desktop and tablet.
Then, to set the URL of the logo, you’ll need this PHP:
add_filter('generate_logo_href', function($href ){ if( 1431 === get_the_ID() ){ $my_url = 'https://www.google.com'; return $my_url; } return $href; },10,1);To set the image and url of the sticky header, you’ll need this PHP as well:
add_filter('generate_sticky_navigation_logo_output',function($output, $img_src, $image){ if( 1431 === get_the_ID() ){ $my_url = 'https://www.google.com'; $logo_src = 'https://cdn.reachingmyworld.com/wp-content/uploads/2022/06/18162522/Daily-Reach-Logo-For-Site.png'; $width = '150px'; $height = '150px'; return sprintf( '<div class="sticky-navigation-logo"> <a href="%1$s" title="%2$s" rel="home"> <img src="%3$s" class="is-logo-image" alt="%2$s" width="%4$s" height="%5$s" /> </a> </div>', $my_url, get_bloginfo( 'name', 'display' ), $logo_src, $width, $height ); } return $output; }, 10, 3);Replace
google.comin both codes to your preference.Kindly let us know.
-
AuthorPosts
- You must be logged in to reply to this topic.