Answer the question
In order to leave comments, you need to log in
How to replace wordpress logo on specific page via function.php?
How to replace wordpress logo in specific function.php page?
I try like this:
add_action( 'custom_logo', 'my_custom_page_logo' );
function my_custom_page_logo(){
echo '
<img class="logo-main scale-with-grid " src="/wp-content/uploads/2021/08/logo-black.png" data-retina="" data-height="93" alt="logo-black" data-no-retina="">
';
}
Answer the question
In order to leave comments, you need to log in
I don't remember such an action 'custom_logo' , but there is a filter 'get_custom_logo' , the code will work when the logo is displayed using the functionthe_custom_logo()
add_filter( 'get_custom_logo', 'custom_logo_url' );
function custom_logo_url( $html ) {
if ( is_home() && is_front_page() ) {
$dir = wp_get_upload_dir();
$html = '<img class="logo-main scale-with-grid" src="' . $dir['baseurl'] . '/2021/08/logo-black.png" data-retina="" data-height="93" alt="logo-black" data-no-retina="">';
}
return $html;
}
is_single()
, is_page()
, is_archive()
, is_front_page()
and similar to execute code for a specific template wp_get_upload_dir()
gets an array of path variations to the downloads directory Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question