— You made a little mistake in code , I resolve this Error in the code So put this code —
function sswc_register_settings()
{
register_setting('sswc_options_group', 'sswc_color_option');
register_setting('sswc_options_group', 'sswc_top_option');
register_setting('sswc_options_group', 'sswc_left_option');
}
add_action('admin_menu', 'sswc_register_settings_page');
function sswc_register_settings_page()
{
add_options_page('Social Sharing with Claps', 'SSWC Settings', 'manage_options', 'sswc', 'sswc_options_page');
add_action('admin_init', 'sswc_register_settings');
}
//Content for settings page will go here
function sswc_options_page()
{
?>
<div class="settings-page-container">
<h1>Social Sharing with Claps</h1>
<h2>Settings</h2>
<form method='post' action='options.php'>
<?php
settings_fields('sswc_options_group');
do_settings_sections( 'sswc_options_group' );
?>
<table>
<tr valign='top'>
<th scope="row"><label class="form-label" for="sswc_color_option">Color Value</label></th>
<td><input type="text" id='sswc_color_option' name="sswc_color_option" value=<?php echo get_option('sswc_color_option');?>></td>
</tr>
<tr valign='top'>
<th scope="row"><label class="form-label" for="sswc_top_option">Top Offset</label></th>
<td><input type="text" id='sswc_top_option' name="sswc_top_option" value=<?php echo get_option('sswc_top_option');?>></td>
</tr>
<tr valign='top'>
<th scope="row"><label class="form-label" for="sswc_left_option">Left Offset</label></th>
<td><input type="text" id='sswc_left_option' name="sswc_left_option" value=<?php echo get_option('sswc_left_option');?>></td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
<?php
}
Output :
[Refer This Link :] https://codex.wordpress.org/Creating_Options_Pages