如何更改任何 WordPress 主題的徽標 URL 鏈接? (包括創世紀主題)
已發表: 2020-12-07
在 Crunchify,我們只發布高質量的教程和代碼片段,它們無需任何更改即可工作。
最近我們還推出了高級服務,也開始銷售高級插件和開發者服務。
最近我們更改了我們的高級網站 ( https://pro.crunchify.com
) 並匹配主題以與主頁 ( https://crunchify.com
) 匹配。
這樣做時,我們注意到最好讓 pro.crunchify.com 的標頭徽標 URL 指向 crunchify.com。
如果您有以下任何問題,此解決方案是否有效?
- 如何更改標題圖像的 URL?
- Genesis 示例主題的徽標 url 更改
- 如何更改主標題圖像的 URL?
- 如何將標題圖像鏈接更改為任何 URL?
- 如何將標題圖片鏈接更改為自定義 URL?
- 如何更改可點擊橫幅的 URL?
- 在 WordPress 中,如何將標題圖像鏈接到自定義 URL?
我一直在尋找解決方案,並聯繫了 Genesis WP 支持團隊。 但除了一些指示和提示外,沒有得到解決。

如您所見,我從Genesis support
團隊沒有得到明確的解決方案。
所以在此之後,我仍在尋找如何在 WordPress 中更改可點擊標題鏈接的解決方案?
最後經過反複試驗,我能夠更改標頭徽標 URL。
這是一個代碼:
只需將其放入主題的 functions.php 文件中,您就可以了。 就我而言,我已將此代碼放入我pro.crunchify.com theme's function.php
文件中。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
function crunchify_custom_logo_url ( $ crunchify_logo_html ) { $ crunchify_custom_logo_id = get_theme_mod ( 'custom_logo' ) ; // Make sure to replace your updated site URL $ crunchify_new_url = 'https://crunchify.com' ; $ crunchify_logo_html = sprintf ( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>' , esc_url ( $ crunchify_new_url ) , wp_get_attachment_image ( $ crunchify_custom_logo_id , 'full' , false , array ( 'class' = > 'custom-logo' , ) ) ) ; return $ crunchify_logo_html ; } // get_custom_logo: Returns a custom logo, linked to home unless the theme supports removing the link on the home page. add_filter ( 'get_custom_logo' , 'crunchify_custom_logo_url' ) ; |
- 請確保將
crunchify_new_url
更改為所需的 URL。
如何驗證?

讓我們檢查一下上面的代碼是否正常工作並且它沒有違反 Google 的任何結構元數據要求?
查看並比較下面的兩個 HTML 標記。
更改 WordPress 標頭徽標 URL 之前
1 2 3 4 5 |
< div class = "title-area" > < a href = "https://pro.crunchify.com/" class = "custom-logo-link" rel = "home" > < img width = "946" height = "198" src = "https://pro.crunchify.com/wp-content/uploads/2019/04/crunchify-pro-logo-white.png" class = "custom-logo" alt = "crunchify-pro-logo-white" srcset = "https://pro.crunchify.com/wp-content/uploads/2019/04/crunchify-pro-logo-white.png 946w, https://pro.crunchify.com/wp-content/uploads/2019/04/crunchify-pro-logo-white-768x161.png 768w" sizes = "(max-width: 946px) 100vw, 946px" data - attachment - id = "2386" data - permalink = "https://pro.crunchify.com/crunchify-pro-logo-white/" data - orig - file = "https://pro.crunchify.com/wp-content/uploads/2019/04/crunchify-pro-logo-white.png" data - orig - size = "946,198" data - comments - opened = "1" data - image - meta = "{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0"}" data - image - title = "crunchify-pro-logo-white" data - image - description = "" data - medium - file = "https://pro.crunchify.com/wp-content/uploads/2019/04/crunchify-pro-logo-white.png" data - large - file = "https://pro.crunchify.com/wp-content/uploads/2019/04/crunchify-pro-logo-white.png" > < / a > < p class = "site-title" > Crunchify Pro < / p > < p class = "site-description" > Premium Services , Plugins & Digital Downloads < / p > < / div > |
更改 WordPress 標頭徽標 URL 後
1 2 3 4 5 |
< div class = "title-area" > < a href = "https://crunchify.com" class = "custom-logo-link" rel = "home" > < img width = "946" height = "198" src = "https://pro.crunchify.com/wp-content/uploads/2019/04/crunchify-pro-logo-white.png" class = "custom-logo" alt = "crunchify-pro-logo-white" loading = "lazy" srcset = "https://pro.crunchify.com/wp-content/uploads/2019/04/crunchify-pro-logo-white.png 946w, https://pro.crunchify.com/wp-content/uploads/2019/04/crunchify-pro-logo-white-768x161.png 768w" sizes = "(max-width: 946px) 100vw, 946px" data - attachment - id = "2386" data - permalink = "https://pro.crunchify.com/crunchify-pro-logo-white/" data - orig - file = "https://pro.crunchify.com/wp-content/uploads/2019/04/crunchify-pro-logo-white.png" data - orig - size = "946,198" data - comments - opened = "1" data - image - meta = "{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0"}" data - image - title = "crunchify-pro-logo-white" data - image - description = "" data - medium - file = "https://pro.crunchify.com/wp-content/uploads/2019/04/crunchify-pro-logo-white.png" data - large - file = "https://pro.crunchify.com/wp-content/uploads/2019/04/crunchify-pro-logo-white.png" > < / a > < p class = "site-title" > Crunchify Pro < / p > < p class = "site-description" > Premium Services , Plugins & Digital Downloads < / p > < / div > |
兩種結構標記看起來都不錯,我看到的唯一區別是徽標 URL。 就是這樣。

我希望這可以幫助您更改主題的標題徽標 URL。
請隨時通過評論讓我們知道您的反饋和評論。