我正在构建一个WordPress主题并且需要在定制器controls中添加自定义,输入字段显示但是当我更改输入的值时没有任何反应。
这是我的代码。
class WP_Customize_Custom_Control extends WP_Customize_Control {
public $type = 'custom_control';
function render_content(){
}
public function content_template() {
?>
<input type="text" id="custom_control" name="custom_control" />
<?php
}
}
function company_customize_register( $wp_customize ){
$wp_customize->register_control_type( 'WP_Customize_Custom_Control' );
$wp_customize->add_setting('custom_smthing', array( 'default' => get_theme_mod( "custom_smthing" ), 'transport' =>'postMessage' ) );
$wp_customize->add_control(new WP_Customize_Custom_Control($wp_customize,'custom_smthing',
array(
'label' => __( 'Custom Control', 'company' ),
'section' => 'body_backgrounds',
'settings' => 'custom_smthing',
)
)
);
}
add_action( 'customize_register', 'company_customize_register' );
Run Code Online (Sandbox Code Playgroud)
而js是
( function( $ ) {
console.log("test1"); …Run Code Online (Sandbox Code Playgroud)