0

I am making a Wordpress theme with a custom admin page. What I did to make it save the settings was this:

<form method="post" action="options.php"> 

When I hit the submit button, I got an error message saying that "options.php" was not found. I attempted to change the general settings and it worked. It was just with my settings page.

Thanks!

EDIT: I just found something on the Codex about this. But I have no idea what it means. It is at the "Notes" section. If someone could help that would be great!

My code:http://pastebin.com/bvXcXhCQ

4
  • I'm not sure why it said options.php not found, but that code isn't going to work - type="text" is for <input> elements, not the <form> element, and the location to load should go in the action attribute not the method. Where did you get this code from?
    – Tim Malone
    Aug 3, 2016 at 4:38
  • Oh, oops. I didn't see my code and I mistaken the type thing. I updated it. Aug 3, 2016 at 12:27
  • 1
    Where is the form getting added? Is it in a settings page, registered with the Settings API? Please show your code so we have more context and aren't left guessing what you're trying to do. Aug 3, 2016 at 13:19
  • @morganestes I updated my question with the code. Aug 3, 2016 at 14:01

3 Answers 3

0

Like @LupuAndrei said, we lack of details, especially the code where you call you form from.

But I suspect, again like @LupuAndrei said, you might not be calling the settings_fields, do_settings_fields or do_settings_sections correctly.

On the function where you build your form, try something like this

<form method="post" action="options.php">
   <table class="form-table">
      <?php 

      settings_fields( 'animated-settings-group' ); // This will output the nonce, action, and option_page fields for a settings page.
      do_settings_sections( 'hoogleyboogley_animated' ); // This prints out the actual sections containing the settings fields for the page in parameter 

      ?>
    </table>

  <?php submit_button(); ?>
</form>
1

Your question lacks a lot of details which could clarify the source of the problem. For example, this error could be also triggered by a wrong call to an add_settings_field function or how settings_fields looks there. These things are essential.

I could try a blind shot and believe that the register_setting function has a different $option_group than $option_name. Try to make the first two parameters to be exactly the same.

Also, you need to take care of your fields. add_settings_field those params must match the register_setting ones

Now if you are really unlucky you could have a problem with whitelist_options filter or some plugin you have installed may crash this.

Personally, I've written a story about how I've got this error and how I've solved it, but it was an isolated case

1
  • I read your page. But I couldn't figure out what you meant by it. I started off with a fresh Wordpress install, so no plugins. Aug 3, 2016 at 14:23
0

Replace your form code as:

<form name="form1" method="POST" action="options.php">

Type is not a Form attribute. To know more form attribute please see: From attribute

3
  • I tried that. It still says options.php not found. Aug 3, 2016 at 11:52
  • @HoogleyBoogley: Update you permalink structure remove name="form1" from the code above. Your form should work after then
    – Shrikant D
    Aug 3, 2016 at 11:59
  • Yes, I did that. Nothing is working. My error is: ERROR: options page not found. Aug 3, 2016 at 12:11

Your Answer

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

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