If I print the value of get_theme_mod( 'enable_sleek_header', false )
it is always the previously saved value. If I print the same thing in the header of the theme, it returns the value from customizer.
- Is it the expected behaviour?
- Am I using the wrong hook?
Thanks
<?php
add_action( 'after_setup_theme', 'pagespeed_register_menus' );
function pagespeed_register_menus() {
//Not getting the modified theme_mod from the customizer without saving.
register_nav_menus( array(
'secondary' => __( 'Navigation above header', 'page-speed' ),
) );
if ( get_theme_mod( 'enable_sleek_header', false ) ) {
register_nav_menus( array(
'header' => __( 'Navigation menu in header', 'page-speed' ),
) );
} else {
register_nav_menus( array(
'primary' => __( 'Navigation below header', 'page-speed' ),
) );
}
register_nav_menus( array(
'footer_links' => __( 'Footer links', 'page-speed' ),
) );
}