2016-08-03 40 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

相關問題