Style Options
-
Hello, I am working on creating a custom style options page for my WordPress style, I have a problem, when say I press submit to update a value, it reloads the page, it says uupdated etc, but nothing changes, until user refreshed page, then it will update, my code:
<?php function setup_theme_admin_menus() { add_menu_page('Open Theme | Options', 'Open theme', 'manage_options', 'open_theme_settings', 'theme_settings_page'); add_submenu_page('open_theme_settings', 'Open Theme | Front Page', 'Front Page', 'manage_options', 'front-page-elements', 'theme_front_page_settings'); } // We also need to add the handler function for the top level menu function theme_settings_page() { $open_width = get_option("open_width"); ?> <div class="wrap"> <?php screen_icon('themes'); ?> <h2>Open Theme Options</h2> <?php $posts = get_posts(); ?> <form method="POST" action=""> <table class="form-table"> <tr valign="top"> <th scope="row"> <label for="num_elements"> Page Width: </label> </th> <td> <input type="text" name="open_width" value="<?php echo $open_width;?>" size="5" /> </td> </tr> </table> <p> <input type="submit" value="Save Settings" class="button"> <input type="hidden" name="update_settings" value="Y" /> </p> </form> </div> <?php if(isset($_POST['update_settings'])) { $open_width = esc_attr($_POST['open_width']); update_option("open_width", $open_width); $open_width = get_option("open_width"); ?> <div id="message" class="updated">Settings saved</div> <?php } } function theme_front_page_settings() { ?> <div class="wrap"> <?php echo "<h2>Open Theme Front Page</h2>"; ?> </div> <?php } add_action("admin_menu", "setup_theme_admin_menus");
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Style Options’ is closed to new replies.