2016-08-03 101 views
3

我想改变我的WordPress的标志链接到一些自定义的。更改我的自定义徽标链接WordPress的

比方说,新的链接我想设置为http://newlink.html

我使用WordPress 4.5.3具有二十15的主题。 (所以我在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();为我的自定义徽标和接下来的两个环节不影响我,因为他们是如果我仍然在使用文字标识,我没有。

我则四处寻找这个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, 
)); 

所以我得到了主意,添加类似'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();,我找不到任何地方。

我可能错过了一些东西或者我没有看正确的方式,如果你能帮助我找到怎样改变我的自定义徽标链接到我的自定义网址,那就太好:)

谢谢!

回答

4

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

工程就像一个魅力,谢谢SOOOO了! :) – Relisora

相关问题