Getting text from custom field from customizer
So I've created a panel in the customizer section in WordPress to add the phone number to the site. It works fine in the back end but it wont show up in the front end
here is my functions.php
function home_smart_register_theme_customizer( $wp_customize ) {
$wp_customize-add_panel( 'contact_info', array(
'priority' = 10,
'theme_supports' = '',
'title' = __( 'Contact Info', 'home_smart' ),
'description' = __( 'Set your current address.', 'home_smart' ),
) );
$wp_customize-add_section( 'contact_details_block' , array(
'title' = __('Phone Number','home_smart'),
'panel' = 'contact_info',
'priority' = 10
) );
$wp_customize-add_setting( 'address_block', array(
'default' = __( 'Default text', 'home_smart' ),
'sanitize_callback' = 'sanitize_text'
) );
$wp_customize-add_control( new WP_Customize_Control(
$wp_customize,
'contact_details_block',
array(
'label' = __( 'Number', 'home_smart' ),
'section' = 'contact_details_block',
'settings' = 'address_block',
'type' = 'text'
)
)
);
function sanitize_text( $text ) {
return sanitize_text_field( $text );
}
}
add_action( 'customize_register', 'home_smart_register_theme_customizer' );
here is my footer.php
p
?php
function add_phone_number(){
echo get_theme_mod('address_block');
}
add_action('home_smart_number', 'add_phone_number');
?
/p
Topic theme-customizer get-theme-mod functions php theme-development Wordpress
Category Web