php - wp_customize and selecting layout -


so i'm trying build conditional statement display different layouts depending on option selected.

having bit of trouble.

$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 (so far) 2 choices. $wp_customize->add_section('layout' , array(     'title' => __('layout','ari'), )); // add our layout section in customize panel. 

displaying our layout.

    <?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; ?> 

just...nothing. i've trawled through codex , can't see i'm doing wrong. doesn't show output.

@stewartside points out that should use get_setting, can't working though. anyone?

get_theme_mod() returns string, not boolean. therefore, if statements fail expecting either 1 or true or 0 or false.

you should using get_setting within $wp_customize functionality.

documentation


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -