为了账号安全,请及时绑定邮箱和手机立即绑定

Wordpress 定制器预览不会刷新functions.php

Wordpress 定制器预览不会刷新functions.php

PHP
人到中年有点甜 2021-06-10 17:36:55
所以我遇到了定制器预览没有完全刷新的问题。只有当我手动刷新页面时,我才能看到我的更改。我的一些代码有助于在下面解释。对于我的定制器设置,我的代码看起来像这样$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',           )) ) );现在在我的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;当我转到定制器并选择“特殊标题”时,这一切都很好接受,定制器会刷新,并且在完全刷新页面之前我看不到我的更改。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 118 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信