I'm trying to create a new admin page in wordpress for some settings. Ideally, I'd like it to be a top-level menu page, but I'd settle for it being a sub-menu under settings. I've followed all the docs, and I have a page that shows up, and the settings are saved. However, I can't get Wordpress to redirect back to the correct page after hitting save.
I finally simply copied and pasted the code from the Codex into my functions.php: http://codex.wordpress.org/Creating_Options_Pages
And I still have the same problem.
The first example redirects to admin.php, which causes a plain white screen while the second example redirects to the main settings page instead of the custom settings sub-page.
Surely there has to be a way to tell Wordpress to redirect to your custom page after saving.
Thanks in advance.
The triggering factor for this might be the form's action
attribute.
Depending on how you save your settings, you probably want to have your action point to options.php
most of the time.
Other than that, settings_field()
is also important in your form. It'll add several hidden input fields to identify the form.
Using this code as an example works perfectly for me at least on WP 3.9.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With