WordPress custom plugin doesn’t find options.php

I am trying to develop a WordPress plugin with a menu page. I am currently just trying to save to options in the menu. But when clicking the submit button, i get an error saying, that the options page could not be found.

Here’s my complete code:


 * Plugin Name: 
 * Plugin URI: 
 * Description: 
 * Version: 1.0.0
 * Author: 
 * License: GPL2

    add_action('admin_menu', 'whatspress_menu');

    function whatspress_menu() {
        add_menu_page('WhatsPress Settings', 'WhatsPress', 'administrator', 'whatspress-settings', 'whatspress_settings_page', 'dashicons-admin-generic');
        add_action( 'admin_init', 'whatspress_settings' );

    function whatspress_settings_page() {
        <div class="wrap">
        <h2>Register Phone</h2>

        <form method="post" action="options.php">
            <?php settings_fields( 'whatspress-settings-group' ); ?>
            <?php do_settings_sections( 'whatspress-settings-group' ); ?>
            <table class="form-table">
                <tr valign="top">
                <th scope="row">Phone Number</th>
                <td><input type="text" name="phonenumber" value="<?php echo esc_attr( get_option('phonenumber') ); ?>" /></td>

                <tr valign="top">
                <th scope="row">Nickname</th>
                <td><input type="text" name="nickname" value="<?php echo esc_attr( get_option('nickname') ); ?>" /></td>

            <?php submit_button(); ?>


    function whatspress_settings() {
        register_setting ('whatspress_settings_group', 'phonenumber');
        register_setting ('whatspress_settings_group', 'nickname');

It obvioulsy redirects to /options.php (snce it’s declared in the action parameter of the form element) which is not in my plugin folder. So I understand the error, but I looked up several tutorials and they seem to do it the same way.

Read more here: WordPress custom plugin doesn’t find options.php

Leave a Reply

Your email address will not be published. Required fields are marked *