Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change my custom logo link Wordpress

Tags:

php

wordpress

I am trying to change my Wordpress logo link into some custom one.

Let's say the new link i want to set is http://newlink.html

I am using wordpress 4.5.3 with twenty fifteen theme. ( so the last answer i fount on Stack is outdated because the custom logo changed in 4.5 ).

I went in header.php and found :

twentyfifteen_the_custom_logo();

    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;

So if i get it correctly, i'm calling a function twentyfifteen_the_custom_logo();for my custom logo and the next two links does not affect me because they are if i still was using the text logo, which I dont.

I then went hunting for this twentyfifteen_the_custom_logo(); and found some parameters I could change :

function.php :

/*
 * Enable support for custom logo.
 *
 * @since Twenty Fifteen 1.5
 */
add_theme_support( 'custom-logo', array(
    'height'      => 248,
    'width'       => 248,
    'flex-height' => true,
) );

So I got the idea to add something like 'src' => http://newlink.html, but the documentation does not look like accepting this parameter.

I continue my hunting to find the function and get to template-tags.phpand find :

if ( ! function_exists( 'twentyfifteen_the_custom_logo' ) ) :
/**
 * Displays the optional custom logo.
 *
 * Does nothing if the custom logo is not available.
 *
 * @since Twenty Fifteen 1.5
 */
function twentyfifteen_the_custom_logo() {
    if ( function_exists( 'the_custom_logo' ) ) {
        the_custom_logo();
    }
}
endif;

This function calls the_custom_logo(); that I can't find anywhere.

I may have missed something or maybe I didn't look the right way, if you could help me finding how to change my custom logo link to my custom url, it would be wonderful :)

Thanks !

like image 379
Relisora Avatar asked Aug 03 '16 07:08

Relisora


1 Answers

Add WordPress filter to change custom logo link as like.

Add in your functions.php file.

http://screencast.com/t/z19OejeBK

add_filter( 'get_custom_logo', 'wecodeart_com' );
function wecodeart_com() {
    $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.google.com' ),
            wp_get_attachment_image( $custom_logo_id, 'full', false, array(
                'class'    => 'custom-logo',
            ) )
        );
    return $html;   
} 
like image 177
Mansukh Khandhar Avatar answered Sep 29 '22 17:09

Mansukh Khandhar