Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sarathlal-old/154374fcd9a5e95665c6961c901f5b4a to your computer and use it in GitHub Desktop.
Save sarathlal-old/154374fcd9a5e95665c6961c901f5b4a to your computer and use it in GitHub Desktop.
First add below code in theme's functions.php file
//Add logo support
function theme_prefix_setup() {
add_theme_support( 'custom-logo', array(
'height' => 60,
'width' => 200,
'flex-width' => true,
) );
}
add_action( 'after_setup_theme', 'theme_prefix_setup' );
//filter site logo and wrapping anchotr tag
add_filter( 'get_custom_logo', 'change_logo_class' );
function change_logo_class( $html ) {
//$html = str_replace( 'custom-logo', 'your-custom-class', $html );
$html = str_replace( 'custom-logo-link', 'navbar-brand', $html );
return $html;
}
Then use below code to get custom logo
<?php
if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment