[Resolved] Logo specific link, staging site to prod site.

Home Forums Support [Resolved] Logo specific link, staging site to prod site.

Home Forums Support Logo specific link, staging site to prod site.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #305572
    movingwaldo

    Hi !

    I needed to change the link on my logo for some pages. So I used the generate_logo_href filter
    like this :
    add_filter( ‘generate_logo_href’,’generate_custom_logo_href’ );
    function generate_custom_logo_href()
    {
    // Enter the URL you want your logo to link to below
    return ‘http://NEW-URL-HERE’;
    }

    It’s working perfectly but my problem is that I did that on my staging site so the logo is linking to my staging site.
    Is it possible that when I update my site from staging to prod, the link (which is a staging link) I put in my filter is automatically updated for a link on my prod site ?

    For example, here is my filter for my staging site :

    add_filter( ‘generate_logo_href’,’tu_add_custom_logo_href’ );
    function tu_add_custom_logo_href( $url )
    {
    if ( is_page( ‘courtier-remax’ ) ) {
    return ‘http://staging.charliedemenage.com/fr/courtier-remax/’;
    }
    if ( is_page( ‘remax-broker’ ) ) {
    return ‘http://staging.charliedemenage.com/remax-broker/’;
    }

    // All the other pages
    return $url;
    }

    You can see the links are http://staging.
    And this is what I need it to be for my prod :

    add_filter( ‘generate_logo_href’,’tu_add_custom_logo_href’ );
    function tu_add_custom_logo_href( $url )
    {
    if ( is_page( ‘courtier-remax’ ) ) {
    return ‘https://www.movingwaldo.ca/fr/courtier-remax/’;
    }
    if ( is_page( ‘remax-broker’ ) ) {
    return ‘https://www.movingwaldo.ca/remax-broker/’;
    }

    // All the other pages
    return $url;
    }

    Here the link is https://www.movingwaldo.ca/

    Is there an other way to change the logo link so it will update it automatically or maybe add a script ??

    Thank you for your answer !

    Alex

    #305615
    Tom
    Lead Developer
    Lead Developer

    You might be able to use the get_permalink() function: https://developer.wordpress.org/reference/functions/get_permalink/

    You would need to grab the ID of your page, and then do this:

    return get_permalink( 10 );

    Where “10” is your page ID.

    #307291
    movingwaldo

    Hi Tom,

    Thanks it worked !

    #307363
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

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