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

Home Forums Support [Resolved] Filter for changing the header-logo on a second page of the website

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

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1429554
    Hans-Hermann Loewer

    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

    #1429563
    Leo
    Staff
    Customer Support

    Hi there,

    This should help:
    https://docs.generatepress.com/article/generate_logo/

    Let me know 🙂

    #1430901
    Hans-Hermann Loewer

    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.

    #1430908
    Leo
    Staff
    Customer Support

    The filter should be the same.

    You just need a different conditional tag:
    https://codex.wordpress.org/Conditional_Tags

    Let me know if I’m still missing something.

    #1430948
    Hans-Hermann Loewer

    Sorry, I´m no coding professional.

    … thought, you could help me …

    #1430973
    Leo
    Staff
    Customer Support

    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; 
     } );
    #1430984
    Hans-Hermann Loewer

    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!

    #1431027
    Leo
    Staff
    Customer Support

    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 🙂

    #1431040
    Hans-Hermann Loewer

    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!

    #1431043
    Leo
    Staff
    Customer Support

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

    #1431051
    Hans-Hermann Loewer

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

    #1431058
    Leo
    Staff
    Customer Support

    Awesome that’s correct 🙂

    #1431062
    Hans-Hermann Loewer

    Thanks again and have a nice weekend without any virus! 😉

    #1431072
    Leo
    Staff
    Customer Support

    You as well!

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.