I want to know whether or not I can dynamically create new settings and controls.
What's the use case? I want non-technical admins to be able to go to the Theme Customizer to be able to add titles and URLs to a "Featured Pages" and "Featured Posts" section of the home page. However, at the current moment, I have to hardcode each setting and control, such as "setting_1", "setting_2", etc.
I've considered using get_theme_mods
, but at this point, I don't know how I could use that with a dynamically generated set of settings and controls.
Here is what I have:
$wp_customize->add_section('sidebar_settings', array(
'title' => 'Feature Sidebar Settings',
'description' => 'The Sidebar section allows you to select feature pages,
posts, and other documents you believe would be valuable
to P2C staff and show them directly on the homepage.',
'priority' => '201'
));
$wp_customize->add_setting('feature_pages', array(
'default' => null,
'capability' => 'edit_theme_options',
'type' => 'theme_mod'
));
$wp_customize->add_control('select_feature_page', array(
'label' => 'Feature Pages',
'section' => 'sidebar_settings',
'settings' => 'feature_pages'
));
if I have to add each setting and control, that's really tedious and not efficient! haha
-Stu
Aucun commentaire:
Enregistrer un commentaire