I want to create the possibility to load a logo via WordPress Customize feature. When I insert logo using get_theme_mod()
– it is only url of image, but I also want get the alternate text of this image.
My code example:
functions.php
function welbit_theme_customizer( $wp_customize ) {
$wp_customize->add_section( 'welbit_logo_section' , array(
'title' => __( 'ÐогоÑип', 'themeslug' ),
'priority' => 30,
'description' => 'ÐагÑÑзиÑе новое изобÑажение.',
) );
$wp_customize->add_setting( 'welbit_logo' );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'welbit_logo', array(
'label' => __( 'Logo', 'welbit' ),
'section' => 'welbit_logo_section',
'settings' => 'welbit_logo',
) ) );
}
add_action( 'customize_register', 'welbit_theme_customizer' );
header.php
<div class="w-header__logo">
<a href="<?php echo get_home_url(); ?>">
<img src="<?php print_r(get_theme_mod('welbit_logo'));?>" alt="<!-- How can I get this? ->" class="logo">
</a>
</div>
Ok I found the answer that no one has on the net I been looking for days now.
Here is how I was able to do it. Hope this helps someone out there
Markup