Support » Theme: Twenty Sixteen » How to change logo URL of twentysixteen theme

Viewing 8 replies - 1 through 8 (of 8 total)
  • Yes, you are in the right direction.

    In your header.php there are two lines written like this:

    
    <?php if ( is_front_page() && is_home() ) : ?>
         <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
    <?php else : ?>
         <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
    <?php endif;
    

    You need to change <?php echo esc_url(home_url('/')) ?> to the web address you want.

    Remember, there is a check <?php if ( is_front_page() && is_home() ) : ?>, which means WordPress will check whether you are on the home page or not. So if you want your logo / site name to always redirect to another URL / site, you need to change both lines.

    So in your case those two lines would look like following:

    
    <?php if ( is_front_page() && is_home() ) : ?>
         <h1 class="site-title"><a href="http://another-site.com" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
    <?php else : ?>
         <p class="site-title"><a href="http://another-site.com" rel="home"><?php bloginfo( 'name' ); ?></a></p>
    <?php endif;
    

    IMPORTANT: Always create Child Theme before customizing because all your changes are GONE when you update the theme!

    Hope this helps!

    • This reply was modified 2 years, 8 months ago by Subrata Sarkar. Reason: Rearranged code block

    This doesn’t seem to work?

    Did you manage to resolve this?

    Hi,
    Sorry, I got pulled into something else for sometime.

    Can you try updating the value of your href in line 90 of header.php please and let me know what you get?

    Thank you.

    Hi,

    This doesn’t seem to work.

    Updated header.php as above but still links to home location of WordPress folder rather than custom URL

    I think the OP (as well as me), are looking to leave the site-title set as the website, but hijack the log url

    setting the logo url in line 90 of header.php seemed promising, but had no effect

    hoping someone has a real answer (sorry @subrataemfluence, your answer works great to hijack the site title by replacing the two <?php echo esc_url( home_url( ‘/’ ) ); ?> references with a unique url, but logo seems unhijackable)

    add to the bottom of your functions.php (this worked for me):

    /*  NOTE: custom additions will get removed any time you update twentysixteen theme; i.e. look into creating twentysixteen-child */
    add_filter( 'get_custom_logo', 'add_custom_logo_url' );
    function add_custom_logo_url() {
        $custom_logo_id = get_theme_mod( 'custom_logo' );
        $html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
                esc_url( 'www.somewhere.com' ),
                wp_get_attachment_image( $custom_logo_id, 'full', false, array(
                    'class'    => 'custom-logo',
                ) )
            );
        return $html;   
    } 
    YENIER Nazim

    (@nazimyenier)

    That works !

    Thanks a lot.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to change logo URL of twentysixteen theme’ is closed to new replies.