add_settings_field – not saving.
-
Hello there,
I am trying to figure this out for 2 hours now. When i create one settings field it works and i can display it on the website, however when i create a second one.. what ever i do i keep getting a empty value on save which results that the first also stops working.. i have tried everything but it’s making me crazy.
Can somebody help?
My code:
/********************************************* * Menu's **********************************************/ function add_custom_settings_page() { add_options_page( 'Demo theme options', // The text to be displayed in the browser title 'Demo theme options', // The text to be used for the menu 'manage_options', // The required capability of users to access this menu 'demo-theme-options', // The slug by which this menu item is accesible 'demo_theme_options_display' // The name of the function used to display the page content ); } add_action('admin_menu', 'add_custom_settings_page'); /********************************************* * Sections, Settings and fields **********************************************/ function demo_theme_options() { // Define the settinge section add_settings_section( 'footer_section', // The ID to use for this section in attribute tags 'Footer options', // The title of the section rendered to the screen 'demo_footer_display', // The function used to render the options for this section 'demo-theme-options' // The ID of the page on which this section is rendered ); // Define the settings field add_settings_field( 'footer_message', // ID of the field 'Theme footer message', // The text of the label field 'footer_message_display', // The callback function used to render the field 'demo-theme-options', // The page on which we'll be rendering this field 'footer_section' // The section to which we're adding the setting ); // Register the 'footer_message' setting with the 'General' section register_setting( 'footer_section', // Register the footer section 'footer_message' // Register the ID of the field ); } add_action('admin_init', 'demo_theme_options'); /********************************************* * CALLBACKS **********************************************/ function demo_theme_options_display() { ?> <div class="wrap"> <h2>Demo theme options</h2> <form method="post" action="options.php"> <?php // Render the settings for the settings section indentified as 'Footer Section' settings_fields('footer_section', 'footer_section_number'); // Renders all of the settings for 'demo-theme-options' section do_settings_sections('demo-theme-options'); // Add a submit button to save our changes submit_button(); ?> </form> <!-- form --> </div> <!-- .wrap --> <?php } function demo_footer_display() { echo '<p>These options are designed to help you control what\'s displayed in your footer.</p>'; } // Display the FIELD for the footer message inside general settings. function footer_message_display() { echo '<input type="text" name="footer_message" id="footer_message" class="regular-text" value="' . get_option('footer_message') . '" />'; }Thanks for the help!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘add_settings_field – not saving.’ is closed to new replies.