douye2110 2011-08-19 17:34
浏览 113
已采纳

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

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:

  • 写回答

1条回答 默认 最新

  • doubei3312 2011-09-04 02:08
    关注

    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 the is_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...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了