Site logo

Archived topic

Filter for changing the header-logo on a second page of the website

13 replies · Started by Hans-Hermann Loewer on September 3, 2020

Viewing posts 1–14 of 14

Hi Tom and crew,

is there any filter or action-script to change the loaded customizer header-logo of the website on a special site when that site is opened?

Inside the forum I couldn´t find the solution, I´m looking for.

Kind regards Hermann

Hi Leo,
I had seen that, but that´s NOT what I need. It´s no site in a category.
I have two other pages within the site, with changes in the header with Tom´s filter like:

add_action( 'option_blogname', 'tu_adjust_blogname' );
function tu_adjust_blogname( $name ) {
if ( is_page( 'new sitename 1' ) ) {
return 'new blogname 1';
}

if ( is_page( 'new sitename 2' ) ) {
return 'new blogname 2';
}
return $name;
}

And now I need to change the logo on those two other sites too.
I´m looking for a filter to arrange an other header-logo for those sites.

Sorry, I´m no coding professional.

... thought, you could help me ...

It should be something like this:

add_filter( 'generate_logo', function( $logo ) {
    if ( is_page( 'page name' ) ) {
        return 'URL TO YOUR LOGO';
    }

    // Otherwise, return our default logo
    return $logo; 
 } );

I tried it. Nothing happened on the second site.

Some questions that perhaps could help me:

If I loaded a logo for the header of the normal pages over
>Customizer >Website-information > Logo

What´s the GP-name of that logo?

generate_logo
header_logo
site_logo
site_header_logo

to address it correctly within the filter.
Thanks for your help, Leo!

Did you clear your caching plugin after adding the code?

Can you copy and paste the code you are adding here?

Make sure to highlight the code and click the code button.

Which page are you trying to change the logo?

Let me know :)

Mea culpa! It´s OK!

My mistake was to create it as a new plug-in.

Now I put it in the mantle functions.php

That´s it!

Thank you very much for your patience, Leo!

Just to make sure you are not adding it in the parent theme's function.php?

No, I put it in the function.php of the child theme mantle to prevent it from beeing tillt with the next GP-update.

Awesome that's correct :)

Thanks again and have a nice weekend without any virus! ;-)

You as well!

This archived topic is closed to new replies.