• Resolved WOWTALKS

    (@wowtalks)


    Hi there,

    I’m using the Primer the Velux child theme. I was hoping you could tell me how to change the url which the logo links to – I want the logo to link to another website. Couldn’t find where to do it anywhere! site is https://ibiza.idiscover360.com/ for reference.

    Best,

    James

Viewing 7 replies - 1 through 7 (of 7 total)
  • By default site logo links to its website URL but of you want to link the logo to another page then you have to edit theme’s header.file but don’t edit the theme files directly, otherwise your changes will be overwritten whenever the theme is updated.

    The best way to make changes like this to a theme is to use a child theme, so your tweaks won’t be overwritten when updating the theme.

    After making the child theme copy template-tags.php (primer/inc/template-tags.php) file in your child theme folder.
    Note: Follow the folder hierarchy

    Find the below code in template-tags.php

    <a href="%1$s" class="custom-logo-link" %2$s>%3$s</a>
    Replace %1$s to the URL you want to link with logo.

    Let us know if you need help with anything else!

    • This reply was modified 7 years, 11 months ago by Poonam Namdev.
    Thread Starter WOWTALKS

    (@wowtalks)

    Sweet. Thanks very much!

    Glad I could help. Please mark this thread as resolved.

    Thread Starter WOWTALKS

    (@wowtalks)

    Hi,

    Sorry, it didn’t work, the logo is still pointing home. Any ideas?

    Best,

    James

    Thread Starter WOWTALKS

    (@wowtalks)

    Because Velux is already a child theme of Primer, creating a new child theme and activating it isn’t possible. I tried adding the template tags file to the velux folder also but it the url remained pointing to home..

    Hi @wowtalks,

    Primer uses the WordPress core function the_custom_logo() which displays the logo.

    WordPress core has a built-in filter for this function called get_custom_logo which allows you to change its output.

    To use it, you will need to create a must-use plugin where you can add PHP code for a filter. Here is a guide from Primer on how to do that (WordPress core filters work the same way as Primer filters do).

    And here is some code (untested) for your plugin that should do the trick:

    <?php
    
    add_filter( 'get_custom_logo', function ( $html ) {
    
    	$new_logo_url = 'https://www.yoururl.com/'; // <-- Just change this.
    
    	$search  = sprintf( '<a href="%s"', esc_url( home_url( '/' ) ) );
    	$replace = sprintf( '<a href="%s"', esc_url( $new_logo_url ) );
    
    	return str_replace( $search, $replace, $html );
    
    } );
    
    Thread Starter WOWTALKS

    (@wowtalks)

    That worked. Good tip to know too! Thanks very much.

    Best,

    James

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Change logo url’ is closed to new replies.