更改我的自定义徽标链接Wordpress

Rel*_*ora 5 php wordpress

我正在尝试将我的Wordpress徽标链接更改为一些自定义链接.

假设我要设置的新链接是http://newlink.html

我正在使用带有二十五个主题的wordpress 4.5.3.(所以我在Stack上的最后一个答案是过时的,因为4.5中的自定义徽标已更改).

我进去header.php发现:

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;
Run Code Online (Sandbox Code Playgroud)

因此,如果我正确地得到它,我正在调用twentyfifteen_the_custom_logo();我的自定义徽标的功能,接下来的两个链接不会影响我,因为如果我仍然使用文本徽标,我不会.

然后我去寻找这个twentyfifteen_the_custom_logo();并发现了一些我可以改变的参数:

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,
) );
Run Code Online (Sandbox Code Playgroud)

所以我想到添加类似的东西,'src' => http://newlink.html,文档看起来不像接受这个参数.

我继续寻找功能,template-tags.php然后找到:

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;
Run Code Online (Sandbox Code Playgroud)

这个函数调用the_custom_logo();我在任何地方都找不到的.

我可能错过了一些东西,或者我看起来不正确,如果你能帮我找到如何将我的自定义徽标链接更改为我的自定义网址,那就太棒了:)

谢谢 !

Man*_*har 9

添加WordPress过滤器以更改自定义徽标链接.

添加您的functions.php文件.

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;   
} 
Run Code Online (Sandbox Code Playgroud)