Note that there are some explanatory texts on larger screens.

plurals
  1. POMy settings are not saving in wordpress theme options page
    primarykey
    data
    text
    <p>I am trying to create a theme options page based on WordPress's Settings API. When I go to check the options.php page in my browser (ex. <a href="http://mysite.com/wordpress/wp-admin/options.php" rel="nofollow">http://mysite.com/wordpress/wp-admin/options.php</a>), I see an entry for coolorange_options but it is empty. This happened after I added a url, width and height to the text fields. </p> <p>So far, I have enough code written to get the information and store it to the database, but not to retrieve it for anything. I referenced a tutorial in the php comment at the top of the code. Considering that I don't know much php or programming, something must be wrong here, I just don't know what. The entire code is below:</p> <pre><code>&lt;?php // This options page mainly follows the WordPress Settings API Tutorial at // http://ottodestruct.com/blog/2009/wordpress-settings-api-tutorial/ add_action('admin_menu', 'theme_admin_add_page'); add_action('admin_init', 'theme_admin_init'); function theme_admin_init() { register_setting('coolorange_theme_options', 'coolorange_options', 'coolorange_options_validate'); // what each parameter represents: add_settings_field($id, $title, $callback, $page, $section, $args); add_settings_section('coolorange_logo_main', 'Logo Section Settings', 'logo_section_text', 'coolorange'); add_settings_field('upload_image_button', '&lt;strong&gt;Upload logo to the Media Folder&lt;/strong&gt;', 'file_upload_button', 'coolorange', 'coolorange_logo_main'); // Upload Logo button add_settings_field('logo_textfields', '&lt;strong&gt;Logo location&lt;/strong&gt;', 'file_location', 'coolorange', 'coolorange_logo_main'); // logo url, width and height text fields add_settings_field('restore_selectbox', '&lt;strong&gt;Restore original heading&lt;/strong&gt;', 'restore_dropdown', 'coolorange', 'coolorange_logo_main'); } function logo_section_text() { echo '&lt;p&gt;In this section, you can replace the standard blog title heading with a custom logo. The logo cannot be wider than &lt;strong&gt;960 pixels&lt;/strong&gt;.&lt;/p&gt;'; } function file_upload_button() { $options = get_option('coolorange_theme_options'); echo '&lt;input id="upload_image_button" class="button-secondary" type="button" name="coolorange_theme_options[upload_image_button]" value="Upload Logo" /&gt;'; } function file_location() { //opens file_location function $options = get_option('coolorange_theme_options'); ?&gt; &lt;h3&gt;How to upload a logo to replace the heading&lt;/h3&gt; &lt;div style="background-color: #FFFFFF; border: 1px solid #BBBBBB; padding: 30px;"&gt; &lt;ul style="list-style: disc;"&gt; ...instructions to upload logo &lt;/ul&gt; &lt;/div&gt; &lt;p&gt;&lt;strong&gt;File URL:&lt;/strong&gt; &lt;input id="image_url" type="text" value="&lt;?php $options['image_url']; ?&gt;" size="60" name="coolorange_theme_options[image_url]" /&gt;&lt;br /&gt; &lt;strong&gt;Logo width:&lt;/strong&gt; &lt;input id="image_width" type="text" value="&lt;?php $options['image_width']; ?&gt;" size="6" name="coolorange_theme_options[image_width]" /&gt; Enter logo width in pixels (for example &lt;strong&gt;800px&lt;/strong&gt;)&lt;br /&gt; &lt;strong&gt;Logo height:&lt;/strong&gt; &lt;input id="image_height" type="text" value="&lt;?php $options['image_height']; ?&gt;" size="6" name="image_height" /&gt; Enter logo height in pixels (for example &lt;strong&gt;90px&lt;/strong&gt;)&lt;/p&gt; &lt;?php } //closes file_location function function restore_dropdown() { //opens restore_dropdown function $options = get_option('coolorange_theme_options'); // http://codex.wordpress.org/Function_Reference/selected ?&gt; &lt;select name="co_restore_selectbox[select_options]" id="co_restore_selectbox"&gt; &lt;option value="default" &lt;?php if ( $co_restore_selectbox['select_options'] == 'default' ) echo 'selected="selected"'; ?&gt;&gt;select an option&lt;/option&gt; &lt;option value="restore" &lt;?php if ( $co_restore_selectbox['select_options'] == 'restore' ) echo 'selected="selected"'; ?&gt;&gt;Restore CSS&lt;/option&gt; &lt;/select&gt; &lt;?php } // closes restore_dropdown funcion function css_switcher() { $options = get_option('coolorange_theme_options'); //$backgroundurl = "url('" . $options['image_url']; . "') top center no-repeat"; ?&gt; &lt;style type="text/css"&gt; &lt;!-- #logo { background: &lt;?php echo $backgroundurl; ?&gt;; width: &lt;?php echo $image_width; ?&gt;; height: &lt;?php echo $image_height; ?&gt;; padding: 1em 2em 0 2em; margin: 0 auto; } #blog-title a { display: block; width: &lt;?php echo $image_width; ?&gt;; height: &lt;?php echo $image_height; ?&gt;; text-indent: -2000px; } #blog-description { text-indent: -2000px; } --&gt; &lt;/style&gt; &lt;?php } // closes css_switcher function add_action('wp_head', 'css_switcher'); function theme_admin_add_page() { add_theme_page('Cool Orange Theme Options','Cool Orange Theme Options','manage_options','coolorange','theme_options_page'); } //Scripts to load WP's Media Library panel //http://www.webmaster-source.com/2010/01/08/using-the-wordpress-uploader-in-your-plugin-or-theme/ function my_admin_scripts() { ...scripts to load media library - unrelated } function my_admin_styles() { ...styles for media library loader } if (isset($_GET['page']) &amp;&amp; $_GET['page'] == 'coolorange') { ...actions to add for media library loader script } function theme_options_page() { ?&gt; &lt;div class="wrap"&gt; &lt;div id="icon-themes" class="icon32"&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2&gt;Cool Orange Theme Options&lt;/h2&gt; &lt;form action="options.php" method="post" name="options_form"&gt;&lt;?php settings_fields('coolorange_theme_options'); ?&gt; &lt;?php do_settings_sections('coolorange'); ?&gt; &lt;input name="Submit" class="button-primary" type="submit" value="&lt;?php esc_attr_e('Save Changes'); ?&gt;" /&gt; &lt;/form&gt; &lt;/div&gt; &lt;?php } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload