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にリンクする方法は?
私はしばらくの間解決策を探していて、GenesisWPサポートチームにも連絡しました。 しかし、いくつかの指針とヒントを除いて、解決策は得られませんでした。

ご覧のとおり、 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のStructureメタデータ要件に違反していないかどうかを確認しましょう。
以下の2つの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を変更するのに役立つことを願っています。
コメントやコメントでお気軽にお知らせください。