Created
November 12, 2017 14:11
-
-
Save asufian97/6fa7b5cae62c0fd9e72f23b86dc9292b to your computer and use it in GitHub Desktop.
wordpress custom theme register logo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//start function.php code | |
function m1_customize_register( $wp_customize ) { | |
$wp_customize->add_setting( 'm1_logo' ); // Add setting for logo uploader | |
// Add control for logo uploader (actual uploader) | |
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'm1_logo', array( | |
'label' => __( 'Upload Logo (replaces text)', 'm1' ), | |
'section' => 'title_tagline', | |
'settings' => 'm1_logo', | |
) ) ); | |
} | |
add_action( 'customize_register', 'm1_customize_register' ); | |
//end function.php | |
?> | |
<?php | |
//start header.php where create dynamic logo | |
?> | |
<?php if ( get_theme_mod( 'm1_logo' ) ) : ?> | |
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="navbar-brand" id="site-logo" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"> | |
<img src="<?php echo get_theme_mod( 'm1_logo' ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"> | |
</a> | |
<?php else : ?> | |
<hgroup> | |
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1> | |
<p class="site-description"><?php bloginfo( 'description' ); ?></p> | |
</hgroup> | |
<?php endif; ?> | |
//end header.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment