Hello, try this code in the functions.php file of your child theme:
function my_custom_logo_link() {
$custom_logo_id = get_theme_mod( 'custom_logo' );
$html = sprintf( '%2$s',
esc_url( 'oceanwp.org' ),
wp_get_attachment_image( $custom_logo_id, 'full', false, array(
'class' => 'custom-logo',
) )
);
return $html;
}
add_filter( 'get_custom_logo', 'my_custom_logo_link' );
Well I did replace the “oceanwp.org” with my custom url. No luck!
This code works, just replace by your own url:
function my_custom_logo_link() {
$custom_logo_id = get_theme_mod( 'custom_logo' );
if ( $custom_logo_id ) {
$custom_logo_attr = array(
'class' => 'custom-logo',
'itemprop' => 'logo',
);
$image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
if ( empty( $image_alt ) ) {
$custom_logo_attr['alt'] = get_bloginfo( 'name', 'display' );
}
$html = sprintf( '%2$s',
esc_url( 'oceanwp.org' ),
wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
);
}
return $html;
}
add_filter( 'get_custom_logo', 'my_custom_logo_link' );
Isn’t working for me 🙁
I tried this to my child theme’s functions.php file..
function my_custom_logo_link() {
$custom_logo_id = get_theme_mod( 'custom_logo' );
if ( $custom_logo_id ) {
$custom_logo_attr = array(
'class' => 'custom-logo',
'itemprop' => 'logo',
);
$image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
if ( empty( $image_alt ) ) {
$custom_logo_attr['alt'] = get_bloginfo( 'name', 'display' );
}
$html = sprintf( '%2$s',
esc_url( 'https://www.bohubrihi.com/' ),
wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
);
}
return $html;
}
add_filter( 'get_custom_logo', 'my_custom_logo_link' );
Oh sorry, I didn’t notice, I can’t add the right code here, delete this code and add this one: http://docs.oceanwp.org/article/473-change-custom-logo-url