Skip to content

Instantly share code, notes, and snippets.

@dotspencer
Created June 1, 2016 14:53
Show Gist options
  • Save dotspencer/ec033c76cdd65fe1d3ec8cc771e65c04 to your computer and use it in GitHub Desktop.
Save dotspencer/ec033c76cdd65fe1d3ec8cc771e65c04 to your computer and use it in GitHub Desktop.
Adding logo to wordpress theme
Put Code In Function.php
function themeslug_theme_customizer( $wp_customize ) {
$wp_customize->add_section( 'themeslug_logo_section' , array(
'title' => __( 'Logo', 'themeslug' ),
'priority' => 30,
'description' => 'Upload a logo to replace the default site name and description in the header',
) );
$wp_customize->add_setting( 'themeslug_logo' );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'themeslug_logo', array(
'label' => __( 'Logo', 'themeslug' ),
'section' => 'themeslug_logo_section',
'settings' => 'themeslug_logo',
) ) );
}
add_action('customize_register', 'themeslug_theme_customizer');
and put this code where you want to display logo:
<?php if ( get_theme_mod( 'themeslug_logo' ) ) : ?>
<div class='site-logo'>
'>
<img src='<?php echo esc_url( get_theme_mod( 'themeslug_logo' ) ); ?>' alt='<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>'>
</div>
<?php endif; ?>
And Customize your theme.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment