@rafatrock You can use this code in your child theme’s functions.php or parent’s:
add_filter( 'twentytwenty_site_logo', function( $html, $args, $classname, $contents ) {
if ( is_page_template( 'templates/template-cover.php' ) && has_custom_logo() ) {
$logo = get_custom_logo();
$logo = preg_replace( '@src="([^"]+)"@', 'src="https://via.placeholder.com/150"', $logo );
$contents = sprintf( $args['logo'], $logo, esc_html( get_bloginfo( 'name' ) ) );
$wrap = $args['condition'] ? 'home_wrap' : 'single_wrap';
return sprintf( $args[ $wrap ], $classname, $contents );
}
return $html;
}, 10, 4 );
In the customizer you start by using the black on white logo and in the above code replace https://via.placeholder.com/150
with the transparent logo’s url.
On every page that uses the cover template it will display the transparent logo.
-
This reply was modified 4 years, 4 months ago by acosmin.
-
This reply was modified 4 years, 4 months ago by acosmin.
I made a custom plugin that has this option in the Customizer, in case you still need it:
https://wordpress.org/plugins/extra-options-for-twenty-twenty/
@acosmin I had the same issue, want to switch between light and dark versions of my logo to account for changes in whether the cover image was present. Your code worked great. Thanks so much!
@meetinghero I’m glad to hear that, you can also use the plugin mentioned above if you want to change it from the Customizer.
Hello,
For some reason the ‘extra options for twenty twenty’ plugin, conflicts with the woocommerce plugin. So I thought I’d use your code above to change the logo image source for the cover template page. But something else happens: there’s no logo visible on the cover template. So the standard logo is gone, and nothing is replacing it.
Do you have any idea how to fix this?
Or: can you tell me how to erase all files of the twenty twenty plugin when removed? So I can completely start over with that plugin? Because on my testsite there is no conflict between the two. So that’s mystifying.
Thank you so much!
Correction:
I was trying css as well, so that nothing showed isn’t completely down to your code. What actually happens when I just use your code:
I see the logo that I see on every page. But when I check elements in my browser I see that the img src has actually changed (that is the right file), the srcset hasn’t.
Sorry for the confusion!
-
This reply was modified 3 years, 11 months ago by renate1975.