这是我的代码:
<div class="col-md-3 target-col desc-marketing" >
<label >Targeted Lists</label>
<div class="select-style" id="targeted-list">
<select class="form-control">
<option id="sendToAll" value="1">
<label for="sendToAll">Send To All Patients</label> </option>
<option id="sendToAllLeads" value="2">↩
<label for="sendToAllProspect">Send To All Prospects</label>
</option>
<option id="sendToAllLeads2" value="3">
<label for="sendToAllLeads">Send To All Leads</label>
</option>
</select>
</div>
<span id="or">OR</span>
</div>
我尝试使用以下代码来获取模板中的值:
function vds_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
$wp_customize->add_section( 'blog_settings' , array(
'title' => __( 'Blog settings', 'vds' ),
'priority' => 30
) );
$wp_customize->add_setting( 'vds[blog_show_commentslink_in_overview]', array(
'default' => '1',
'type' => 'option'
) );
$wp_customize->add_control( 'blog_show_commentslink_in_overview', array(
'label' => __( 'Show comments link in blog overview?' ),
'section' => 'blog_settings',
'settings' => 'vds[blog_show_commentslink_in_overview]',
'type' => 'checkbox',
'std' => '1'
) );
}
add_action( 'customize_register', 'vds_customize_register' );
他们都没有工作:/为什么?存储实际值我猜是因为如果我在自定义程序中取消激活复选框并重新加载自定义程序,则取消选中该复选框,以便保存它。
答案 0 :(得分:0)
$variable = get_theme_mod( 'vds[blog_show_commentslink_in_overview]' ) == '1' ? '// what to run' : '';
echo $variable;
这就是我使用的。