php – 更改我的自定义徽标链接WordPress

我正在尝试将我的Wordpress徽标链接更改为一些自定义链接.假设我要设置的新链接是http://newlink.html我正在使用带有二十五个主题的wordpress 4.5.3. (所以我在Stack上的最后一个答案是过时的,因为4.5中的自定义徽...

我正在尝试将我的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;

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

然后我去寻找这个二十五__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,
) );

所以我想到了添加’src’=>之类的东西. http://newlink.html,但documentation看起来不像接受这个参数.

我继续寻找功能并转到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;

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

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

谢谢 !

最佳答案:

添加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;   
} 

本文标题为:php – 更改我的自定义徽标链接WordPress

基础教程推荐