admin管理员组

文章数量:1026982

This question already has answers here: Change logo url link (8 answers) Closed 6 years ago.

i've tried to change the logo link in the homepage with this code i've found:

<?php echo esc_url( home_url( '/home' ) ); ?>

this in the header.php but doesn't work, also i tried

add_filter( 'login_headerurl', 'custom_login_logo_url' );function custom_login_logo_url($url) {
return '/home';}

doesn't work.

Thanks

This question already has answers here: Change logo url link (8 answers) Closed 6 years ago.

i've tried to change the logo link in the homepage with this code i've found:

<?php echo esc_url( home_url( '/home' ) ); ?>

this in the header.php but doesn't work, also i tried

add_filter( 'login_headerurl', 'custom_login_logo_url' );function custom_login_logo_url($url) {
return '/home';}

doesn't work.

Thanks

Share Improve this question asked Mar 29, 2019 at 16:55 Andrea CaprettiAndrea Capretti 632 silver badges6 bronze badges 4
  • Hey Andrea :) Please check the question thread @leymannx linked to, specifically this answer by Jack Johansson. – jsmod Commented Mar 29, 2019 at 21:03
  • Thanks guys, i tried to add this code function mb_login_url() { return home_url('/home'); } add_filter( 'login_headerurl', 'mb_login_url' ); but it doesn't work, maybe I made some mistakes? – Andrea Capretti Commented Mar 29, 2019 at 21:53
  • Where are you adding it? It should be in functions.php, a file linked therein, or a plug-in --- not in a template file. – tmdesigned Commented Mar 29, 2019 at 22:47
  • Yes, I added the code in my functions.php in the child theme – Andrea Capretti Commented Mar 29, 2019 at 23:21
Add a comment  | 

1 Answer 1

Reset to default 1

The example code you've posted, as the documentation states, "Filters link URL of the header logo above login form" (emphasis mine). However, you are asking about changing the URL for the site logo (which I assume is somewhere in the header of every page).

Normally this is done via the theme customizer. Depending on the theme, however, this feature may or may not be implemented. In the twentynineteen theme, in the template template-parts/header/site-branding.php on line 13 you can see where the logo is printed: <div class="site-logo"><?php the_custom_logo(); ?></div>. The function the_custom_logo() includes all the HTML necessary to display the site logo and link.

Assuming you are using twentynineteen as the parent theme, you would need to do the following:

  1. Copy header.php from the parent twentynineteen theme into the root of your child theme
  2. Create a new folder in your child theme called template-parts
  3. Create a new folder inside template-parts called header
  4. Copy the file site-branding.php from the parent theme (in template-parts/header) into your child theme in the same location.
  5. Modify lines 12 through 14 of site-branding.php as needed (remove the existing lines 12 through 14 and add the A and IMG elements for the logo)

Again, the exact method for how you should do it depends entirely on the the theme you are using.

--- Edited 2019-04-01 ---

I don't know what version of the Kalium theme you use nor if you are using the premium version but I did find a version online and it has a kalium_logo_url filter. Assuming this filter is present in your theme, if you add the following to the child functions.php file, it should do what you are intending:

add_filter( 'kalium_logo_url', function() {
   return '/home'; 
});

Please, if this solves your issue, mark this as the answer.

This question already has answers here: Change logo url link (8 answers) Closed 6 years ago.

i've tried to change the logo link in the homepage with this code i've found:

<?php echo esc_url( home_url( '/home' ) ); ?>

this in the header.php but doesn't work, also i tried

add_filter( 'login_headerurl', 'custom_login_logo_url' );function custom_login_logo_url($url) {
return '/home';}

doesn't work.

Thanks

This question already has answers here: Change logo url link (8 answers) Closed 6 years ago.

i've tried to change the logo link in the homepage with this code i've found:

<?php echo esc_url( home_url( '/home' ) ); ?>

this in the header.php but doesn't work, also i tried

add_filter( 'login_headerurl', 'custom_login_logo_url' );function custom_login_logo_url($url) {
return '/home';}

doesn't work.

Thanks

Share Improve this question asked Mar 29, 2019 at 16:55 Andrea CaprettiAndrea Capretti 632 silver badges6 bronze badges 4
  • Hey Andrea :) Please check the question thread @leymannx linked to, specifically this answer by Jack Johansson. – jsmod Commented Mar 29, 2019 at 21:03
  • Thanks guys, i tried to add this code function mb_login_url() { return home_url('/home'); } add_filter( 'login_headerurl', 'mb_login_url' ); but it doesn't work, maybe I made some mistakes? – Andrea Capretti Commented Mar 29, 2019 at 21:53
  • Where are you adding it? It should be in functions.php, a file linked therein, or a plug-in --- not in a template file. – tmdesigned Commented Mar 29, 2019 at 22:47
  • Yes, I added the code in my functions.php in the child theme – Andrea Capretti Commented Mar 29, 2019 at 23:21
Add a comment  | 

1 Answer 1

Reset to default 1

The example code you've posted, as the documentation states, "Filters link URL of the header logo above login form" (emphasis mine). However, you are asking about changing the URL for the site logo (which I assume is somewhere in the header of every page).

Normally this is done via the theme customizer. Depending on the theme, however, this feature may or may not be implemented. In the twentynineteen theme, in the template template-parts/header/site-branding.php on line 13 you can see where the logo is printed: <div class="site-logo"><?php the_custom_logo(); ?></div>. The function the_custom_logo() includes all the HTML necessary to display the site logo and link.

Assuming you are using twentynineteen as the parent theme, you would need to do the following:

  1. Copy header.php from the parent twentynineteen theme into the root of your child theme
  2. Create a new folder in your child theme called template-parts
  3. Create a new folder inside template-parts called header
  4. Copy the file site-branding.php from the parent theme (in template-parts/header) into your child theme in the same location.
  5. Modify lines 12 through 14 of site-branding.php as needed (remove the existing lines 12 through 14 and add the A and IMG elements for the logo)

Again, the exact method for how you should do it depends entirely on the the theme you are using.

--- Edited 2019-04-01 ---

I don't know what version of the Kalium theme you use nor if you are using the premium version but I did find a version online and it has a kalium_logo_url filter. Assuming this filter is present in your theme, if you add the following to the child functions.php file, it should do what you are intending:

add_filter( 'kalium_logo_url', function() {
   return '/home'; 
});

Please, if this solves your issue, mark this as the answer.

本文标签: Change homepage39s logo link