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.
-Stu
]]>REQUIRED: Found a Customizer setting that did not have a sanitization callback function. Every call to the add_setting() method needs to have a sanitization callback function passed.
RECOMMENDED: No reference to add_theme_support( "title-tag" ) was found in the theme. It is recommended that the theme implement this functionality for WordPress 4.1 and above.
The latter is probably not crucial, but it would be nice to be corrected as well. But I am more worried about the error marked REQUIRED.
Could someone figure out hot to correct this?
I have added my own panels to the theme customizer API via the add_section, add_setting and add_control functions.
I’d like to be able to make certain settings appear depending on the selection of a radio button (the same way the static front page section works).
For example if the user selects a radio button with the value of “page” then I want a dropdown-pages control to be shown. But if the user selects a radio button with the value of “iframe” i’d like to render a normal text field for them to enter a URL in.
I’m unable to find any documentation related to using javascript to show and hide customizer controls during use or whether this can be done natively via the API. The static front page section is defined in class-wp-customize-manager.php but this hasn’t yielded any useful information.
Thanks in advance.
Ryan
I’m working on a thema with an extended customization panel. I’m creating a social media section, but the array of social media networks seen below is not being sorted correctly.
Maybe it’s because I didn’t put the values alphabetically first and now the old order is still being saved in some “hidden corner” of the system… When I do a print_r()
of the sorted array, it’s being sorted correctly, but the output in the customization panel is not correct.
Any idea? Thank you!
function mytheme_customize_extend( $wp_customize ) {
/* Social Media customizer section */
$wp_customize->add_section( 'mytheme_section_socialmedia' , array(
'title' => __( 'Social Media Links', 'mytheme' ),
'priority' => 40,
));
$social_media_settings = array('aim','behance','digg','dribbble','ember','evernote','facebook','flickr','forrst','github','googleplus','lastfm','linkedin','paypal','rss','sharethis','skype','soundcloud','tumblr','twitter','vimeo','wordpress','yahoo','youtube','zerply');
sort($social_media_settings);
foreach($social_media_settings as $key => $setting) {
$setting_shortname = 'link_'.$setting;
$setting_output = ucfirst($setting);
$setting_name = 'mytheme_theme_options['.$setting_shortname.']';
$wp_customize->add_setting($setting_name, array(
'default' => '',
'capability' => 'edit_theme_options',
));
$wp_customize->add_control( new WP_Customize_Control($wp_customize, $setting_shortname, array(
'label' => sprintf(__( 'Link to %s page', 'mytheme' ).' '.$key, $setting_output),
'section' => 'mytheme_section_socialmedia',
'settings' => $setting_name,
)));
}
}
add_action( 'customize_register', 'mytheme_customize_extend' );
]]>‘add_section’ has a ‘priority’ argument. so I can re-order of section. but I don’t know well how to change the order of settings.
]]>