Theme options fields won't save
-
Im making my very first theme, and i’ve come to the part where i want to create theme-options.
To start with i will just create a custom footer text, I’ve followed some tutorials, and i have everything nailed down, but the saving part. It doesn’t seem to save my option.
Here is my code from functions.php
function setup_theme_admin_menus() { add_submenu_page( 'themes.php', 'Theme Options', 'Theme Options', 'manage_options', 'theme-options', 'theme_options_settings' ); } function theme_options_settings() { // Check that the user is allowed to update options if (!current_user_can('manage_options')) { wp_die('You don't have access to this page.'); } ?> <div class="wrap"> <?php screen_icon(); ?><h2> Theme Settings </h2> <form method="POST" action=""> <table class="form-table"> <tr valign="top"> <th scope="row"> <label for="footer_text"> Footer Text: </label> </th> <td> <input type="text" name="footer_text" value="<?php echo $footer_text;?>" size="25" /> </td> </tr> </table> <p> <input type="submit" value="Save Settings" class="button-primary"/> </p> <input type="hidden" name="update_settings" value="Y" /> </form> </div> <?php if (isset($_POST["update_settings"])) { $footer_text = esc_attr($_POST["footer_text"]); update_option("theme_name_footer_text", $footer_text); ?> <div id="message" class="updated">Settings saved</div> <?php } } add_action("admin_menu", "setup_theme_admin_menus");And this is the code from my footer.php
<footer> <?php $footer_text = get_option("theme_name_footer_text"); ?> <p><?php echo $footer_text ?></p> </footer>Another thing is, i can’t seem to get the icon to show in front of the title. I used the screen_icon(); function.
Hope you can help me
The topic ‘Theme options fields won't save’ is closed to new replies.