If you want to add Custom Logo in your wordpress theme. you can follow below steps.
1) Adding Custom Logo support to your Theme
To enable the use of a custom logo in your theme, add the following to your functions.php file:
add_theme_support( 'custom-logo' );
2) Displaying the custom logo in your theme
If you want to get your current logo. Open the file where you want the theme logo to appear.
<?php
$custom_logo_id = get_theme_mod( 'custom_logo' );
$logo = wp_get_attachment_image_src( $custom_logo_id, 'full' );
if ( has_custom_logo() ) {
echo '<img class="img-fluid" src="' . esc_url( $logo[0] ) . '" alt="'. get_bloginfo( 'name' ) .'">';
} else {
echo '<h1>' . get_bloginfo( 'name' ) . '</h1>';
}
?>
3) Setup custom logo in your dashboard
Last Update on:March 5th, 2023 at 5:19 pm