【发布时间】:2015-05-13 19:38:08
【问题描述】:
所以我正在尝试构建一个条件语句来根据所选选项显示不同的布局。
有点麻烦。
$wp_customize->add_setting('layout', array(
'default' => 'stream',
)); // add our default setting.
$wp_customize->add_control('layout', array(
'label' => __('Select layout', 'Ari'),
'section' => 'layout',
'settings' => 'layout',
'type' => 'radio',
'choices' => array(
'stream' => 'Stream',
'grid' => 'Grid',
),
)); // use radio buttons with (so far) two choices.
$wp_customize->add_section('layout' , array(
'title' => __('Layout','Ari'),
)); // add our layout section in the customize panel.
显示我们的布局。
<?php if ( get_theme_mod( 'stream' ) ) : ?>
<p>stream</p> if ( have_posts() ) etc
<?php elseif ( get_theme_mod( 'grid' ) ) : ?>
<p>grid</p> // if ( have_posts() ) etc
<?php else : //Nothing ?>
<?php endif; ?>
只是……没什么。我已经翻阅了法典,我看不出我做错了什么。它只是没有显示任何输出。
@Stewartside 指出我应该使用 get_setting,但我无法使其正常工作。有人吗?
【问题讨论】:
标签: php wordpress customization