我已经为Wordpress Customizer做了一个自定义控件,我想在脚本(Instafeed.js)中设置我的控件来改变limit数字.
根据这个答案,这就是我到目前为止的做法
<script type="text/javascript">
var userFeed = new Instafeed({
get: '',
tagName: '',
clientId: '',
limit: var imglimit = <?php echo json_encode($imglimit); ?>;,
});
userFeed.run();
</script>
Run Code Online (Sandbox Code Playgroud)
功能
$wp_customize->add_setting(
'imglimit',
array(
'default' => '',
'section' => 'section',
));
$wp_customize->add_control('imglimit', array(
'label' => __('test'),
'section' => 'section',
'settings' => 'imglimit',
'type' => 'select',
'choices' => array(
'5' => '5',
'10' => '10',
'20' => '20',
),
));
function theme_customizer()
{
$imglimit = get_theme_mod('imglimit');
}
Run Code Online (Sandbox Code Playgroud)
谁能告诉我哪里出错了?我一直在寻找这个.