所以我遇到了定制器預(yù)覽沒有完全刷新的問題。只有當(dāng)我手動(dòng)刷新頁面時(shí),我才能看到我的更改。我的一些代碼有助于在下面解釋。對于我的定制器設(shè)置,我的代碼看起來像這樣$wp_customize->add_section( 'theme_layout', array( 'title' => __( 'Layout', 'theme' ), 'priority' => 30) );$wp_customize->add_setting( 'theme_header_layout', array( 'default' => 'default', 'transport' => 'refresh',) );$wp_customize->add_control( new WP_Customize_Control( $wp_customize,'theme_header_layout', array( 'label' => __( 'Header', 'theme' ), 'section' => 'theme_layout', 'settings' => 'theme_header_layout', 'type' => 'select', 'choices' => array( 'default' => 'default', 'special_header' => 'Special Header', )) ) );現(xiàn)在在我的functions.php中我有這樣的代碼//this is the code that doesn't seem to execute when the customizer refreshesif ( 'special_header' == get_theme_mod( 'theme_header_display' ) ): function theme_special_header( $items ) { $items .= do_shortcode('[special_header_shortcode]');//This shortcode exists I just didnt bother mentioning it here } add_action( 'wp_nav_menu_secondary-menu_items', 'theme_special_header' );//Adds shortcode to menu with id of secondary-menuendif;當(dāng)我轉(zhuǎn)到定制器并選擇“特殊標(biāo)題”時(shí),這一切都很好接受,定制器會(huì)刷新,并且在完全刷新頁面之前我看不到我的更改。
Wordpress 定制器預(yù)覽不會(huì)刷新functions.php
人到中年有點(diǎn)甜
2021-06-10 17:36:55