如何更改任何 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。
请随时通过评论让我们知道您的反馈和评论。