如果我打印get_theme_mod( \'enable_sleek_header\', false )
它始终是以前保存的值。如果我在主题的标题中打印相同的内容,它将从customizer返回值。
这是预期的行为吗我用错钩子了吗谢谢
<小时>
<?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\' ),
) );
}