0

I am building a custom theme from the Underscores starter theme (https://underscores.me/), and am building a theme settings page. When I go to save my fields, I get the "Error: options.php not found" page....upon save, the site is visiting localhost:8888/themename/wp-admin/options.php, and I DO have that options.php file in that directory, so I'm not sure why it isn't found. I understand it's looking for options.php because I have a "post" to options.php in my form, but I'm not sure how I would avoid that..

In any case, this is what I have for my Theme Settings page in my functions.php

    function theme_settings_page(){

        echo "<div class='wrap'>
        <h1>Theme Panel</h1>
        <form method='post' action='options.php'>";

                settings_fields("section");
                do_settings_sections("theme-options");
                submit_button();

       echo "</form>
        </div>";

}

function add_theme_menu_item()
{
    add_menu_page("Theme Panel", "Theme Panel", "manage_options", "theme-panel", "theme_settings_page", null, 99);
}

add_action("admin_menu", "add_theme_menu_item");



function display_facebook_element(){
    $fbookUrl = get_option('facebook_url');

        echo "<input type='text' name='facebook_url' id='facebook_url' value=$fbookUrl>";

}

function display_theme_panel_fields(){
    add_settings_section("social", "Social Media", null, "theme-options");

  add_settings_field("facebook_url", "Facebook Profile Url", "display_facebook_element", "theme-options", "social");


  register_setting("social", "facebook_url");
}

add_action("admin_init", "display_theme_panel_fields");

Any help would be much appreciated!!!!

  • 1
    Why is your call to settings_fields referencing section? I see no other references to a settings section named section – Tom J Nowell Aug 7 '18 at 1:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.