I've created a really simple theme settings page to just enable my user to add some social media links. However when I input some data and save the fields the text vanish's and doesn't seem to save.
<?php
// create custom theme settings menu
add_action('admin_menu', 'getextra_settings_create_menu');
function getextra_settings_create_menu() {
//create new top-level menu
add_menu_page('Theme Settings', 'Theme Options', 'administrator', __FILE__, 'ge_settings_callback_page');
//call register settings function
add_action( 'admin_init', 'register_mysettings' );
}
function register_mysettings() {
//register our settings
register_setting( 'theme-settings-group', 'theme_options' );
}
function ge_settings_callback_page() {
?>
<div class="wrap">
<h2>Foxyrentals Theme Settings</h2>
<form method="post" action="options.php">
<?php settings_fields( 'theme-settings-group' ); ?>
<?php do_settings_sections( 'theme-settings-group' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">Facebook</th>
<td><input type="text" name="facebook" value="<?php echo get_option('facebook'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Twitter</th>
<td><input type="text" name="twitter" value="<?php echo get_option('twitter'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Pinterest</th>
<td><input type="text" name="pinterest" value="<?php echo get_option('pinterest'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Google+</th>
<td><input type="text" name="googleplus" value="<?php echo get_option('googleplus'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Linkedin</th>
<td><input type="text" name="linkedin" value="<?php echo get_option('linkedin'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Foursquare</th>
<td><input type="text" name="foursquare" value="<?php echo get_option('foursquare'); ?>" /></td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
<?php } ?>
from this I've created a function that displays these options in the footer using the following;
<?php
function social_icons() {
$facebook = get_option('facebook');
$twitter = get_option('twitter');
$googleplus = get_option('googleplus');
$linkedin = get_option('linkedin');
$foursquare = get_option('foursquare');
$pinterest = get_option('pinterest');
?>
<a href="<?php echo $facebook; ?>"<img src="<?php bloginfo('template_url'); ?>/images/icon_fb.png" alt="facebook" /></a>
<a href="<?php echo $twitter; ?>"><img src="<?php bloginfo('template_url'); ?>/images/icon_tw.png" alt="twitter" /></a>
<a href="<?php echo $googleplus; ?>"><img src="<?php bloginfo('template_url'); ?>/images/google-icon.png" alt="googleplus" /></a>
<a href="<?php echo $linkedin; ?>"><img src="<?php bloginfo('template_url'); ?>/images/pinterest-icon.png" alt="pinterest" /></a>
<a href="<?php echo $pinterest; ?>"><img src="<?php bloginfo('template_url'); ?>/images/linkedin-icon.png" alt="linkedin" /></a>
<a href="<?php echo $foursqaure; ?>"><img src="<?php bloginfo('template_url'); ?>/images/foursquare-2-icon.png" alt="foursqaure" /></a>
<?php } ?>