Frustrated SO regular here:
I’m creating a theme-options.php page for a child theme in WordPress. Here’s the code. The page renders correctly, including: Adding the page link to the correct admin menu, creating and displaying the options page. When I click save, however, it takes me to a 500 (internal server error page).
Using the ‘adminer’ plugin (phpmyadmin) I have looked at the wp_options table, and there are none of the custome settings/fields that I have specified. My best guess at the problem is that the settings aren’t registering properly so when I post the form to options.php it responds with an error because it doesn’t expect those form fields.
I’ve been wracking my brain around this code for a few days now, and am wondering if someone else can take a look at it for me? I would really appreciate a few extra eyes…
Some resources I have tried:
- http://ottopress.com/2009/wordpress-settings-api-tutorial/
- http://themeshaper.com/2010/06/03/sample-theme-options/
- http://codex.wordpress.org/Function_Reference/add_settings_section
- My settings are not saving in wordpress theme options page (his settings appear empty in db. mine don’t appear at all)
Oh crud,
It dawned on me after I spent an hour figuring it out that Richard M had given you the answer.
I created a new paste of your code, cleaned up some: http://pastebin.com/enUa3xme
I fixed the issue and also added the function
add_my_options()and removed theis_admin()wrapper around your admin action hooks since they will only be triggered in the admin area, so they are unnecessary.I needed to learn this since I use a half-way-done implementation of this, so even if it isn’t helpful to you, it was worth learning…