0

Hello I'm currently following a guide on how to add input to my created Sub Menu Pages. Here is a pic of what is showing up.When I view the sub-menu page.

No Errors, just not showing the text field. The Function function mytheme_general_name() is not getting called in the 2nd add_submenu_page, but I don't see what is wrong with it.

I copied the Here is my Current two php files in use

File Name: function-admin.php

/*

@package Jeron

    ========================
        ADMIN PAGE
    ========================
*/

function mytheme_add_theme_options() {
    // Generate Theme Options Page
    add_menu_page('My Themes Theme Options', 'Theme Options', 'manage_options', 'theme2_options', 'mytheme_create_page', get_template_directory_uri().'/img/themeoptionsicon.png', 110);

    // Generate Theme Options Sub Pages
    add_submenu_page('theme2_options', 'Theme Options', 'General', 'manage_options', 'theme2_options', 'mytheme_create_page');
    add_submenu_page('theme2_options', 'Typography', 'Typography', 'manage_options', 'theme_options_typography', 'mytheme_create_typography_page');
}

add_action('admin_menu', 'mytheme_add_theme_options');

// Activate Custom Settings
add_action('admin_init', 'mytheme_custom_settings');

function mytheme_custom_settings() {
    register_setting('mytheme-settings-group', 'first_name');
    add_settings_section('mytheme-general-options', 'General Settings', 'mytheme_general_options', 'theme2_options');
    add_settings_field('general-name', 'First Name', 'mytheme_general_name', 'theme2_options', 'mytheme_settings_group');
}

function mytheme_general_options() {
    echo 'Customize Your Theme Options Below';
}

function mytheme_general_name() {
    $firstName = esc_attr(get_option('first_name'));
    echo '<input type="text" name="first_name" value="'.$firstName.'" placeholder="First Name" />';
}

function mytheme_create_page() {
    require_once(get_template_directory().'/inc/templates/mytheme-admin.php');
}

function mytheme_create_typography_page() {
    echo '<h1>My Theme Typography</h1>';
}

?>

File Name: mytheme-admin.php

<h1>My Theme Options</h1>
<?php settings_errors(); ?>
<form method="post" action="options.php">
    <?php settings_fields('mytheme_settings_group');?>
    <?php do_settings_sections( 'theme2_options' ); ?>
    <?php submit_button(); ?>
</form>
2
  • there is a opening php tag sorry about that.
    – Jeron Gunn
    Jul 7, 2017 at 15:31
  • Also here is the correct code I'm suppose to be following, I've looked/compared and I can't find what is wrong github.com/Alecaddd/Sunset-theme
    – Jeron Gunn
    Jul 7, 2017 at 15:36

1 Answer 1

-1

Replaced mytheme_settings_group with mytheme-general-options, I thought this was the section id, not a unique id. Thanks for everyones time who reads this. Hopefully it helps someone else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.