简体   繁体   English

Wordpress没有从options.php页面注册自定义选项

[英]Wordpress not registering custom options from options.php page

Frustrated SO regular here: 沮丧的SO常规在这里:

I'm creating a theme-options.php page for a child theme in Wordpress. 我正在为Wordpress中的子主题创建一个theme-options.php页面。 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). 但是,当我单击“保存”时,它会转到500(内部服务器错误页面)。

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. 使用'adminer'插件(phpmyadmin)我查看了wp_options表,并且没有我指定的客户设置/字段。 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. 我对问题的最好猜测是设置没有正确注册,因此当我将表单发布到options.php时,它会响应错误,因为它不会指望那些表单字段。

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: 我试过的一些资源:

Oh crud, 哦,好吧,
It dawned on me after I spent an hour figuring it out that Richard M had given you the answer. 在我花了一个小时搞清楚理查德M给你答案后,我突然意识到了这一点。

I created a new paste of your code, cleaned up some: http://pastebin.com/enUa3xme 我创建了一个新的代码粘贴,清理了一些: http//pastebin.com/enUa3xme

I fixed the issue and also added the function add_my_options() and removed the is_admin() wrapper around your admin action hooks since they will only be triggered in the admin area, so they are unnecessary. 我修复了这个问题并添加了函数add_my_options()并删除了管理操作挂钩周围的is_admin()包装器,因为它们只会在管理区域中触发,所以它们是不必要的。

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... 我需要学习这个,因为我使用了这个中途完成的实现,所以即使它对你没有帮助,也值得学习......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM