I am working on a plugin and on the settings page I have 2 settings and I want to show Only one setting "backgroundColor" so how should i do that?
This is the code:
<form action="options.php" method="post">
<?php
settings_errors();
settings_fields( 'bg_color' ); **<<< I want only background settings to show how i can do it correclty?**
do_settings_sections( 'plugin-style' );
submit_button( __('Save settings', 'trans') );
?>
</form>
/* Add Settings Field for Background Color */
add_settings_field(
'background-color',
__('Background Color', 'trans'),
'plugin_background_color_ca',
'plugin-style',
'style-settings-section-2',
array(
'name' => 'bg_color',
'id' => 'style-settings-background-color',
'class' => 'style-settings-background-color',
'options' => $style_opts,
)
);
/* Add Settings Field for Font Size */
add_settings_field(
'st-search-font-size',
__('Font Size', 'trans'),
'plugin_font_size_ca',
'plugin-style',
'style-settings-section-2',
array(
'name' => 'font_size',
'id' => 'style-settings-font-size',
'class' => 'style-settings-font-size',
'options' => $style_opts,
)
);
N
settings_fields
is just for the nonces and hidden inputs, it doesn't display the settings on the page. What's the problem that requires you to only show this? Are you trying to implement tabs or accordions? I'm not sure why you would register a section, put 2 settings in it, but only show 1