admin管理员组文章数量:1122832
I'm trying to create an option within the customizer that is basically a list of pages with checkboxes. I have that part working but I don't understand how to save it AND how to retrieve the saved data.
This is what I have so far...
class Customize_Pages_Control extends WP_Customize_Control {
public $type = 'pages';
public function render_content() {
$pages = get_pages(); ?>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<?php
foreach ($pages as $page) { // Loop through pages and add checkboxes
?>
<label>
<input type="checkbox" value="<?php echo $page->ID ?>">
<?php echo $page->post_title; ?>
</label> <?php
}
}
}
$wp_customize->add_setting('list_pages' , array(
'capability' => 'edit_theme_options',
));
$wp_customize->add_control(new Customize_Pages_Control($wp_customize, 'list_pages', array(
'label' => __( 'Add pages to slideshow' ),
'section' => 'options_ga_code',
'settings' => 'list_pages',
'type' => 'pages',
)));
本文标签: phpWordPress CustomizerHow to save list of checkbox of pages
版权声明:本文标题:php - WordPress Customizer - How to save list of checkbox of pages? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736306592a1933012.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论