构建wordpress插件的500服务器错误

时间:2012-03-08 15:47:24

标签: wordpress plugins

我正在编写一个插件,根据表单指定的数量创建类别。所以我有表单页面,它可以工作,你可以从仪表板菜单访问它。当表单发布时,它会发送到带有此代码的php页面:

//includes this file so that I can use wordpress functions
include '../../../wp-includes/pluggable.php';
//comes from the amount specified by the form
$assignmentamout = $_POST['assignmentamout'];
//comes from what to call the categories input part of the form
$namethem = $_POST['namethem'];

//if the input box for naming the assignments is blank, this is the default
if($namethem == "") $namethem = 'Assignment';

//repeat the createcat categories function for as many times as stated in the form
for ($i = 1; $i <= $assignmentamout; $i++) {
    $create = $namethem." ".$i;
    createcat($create);
}
//run this function as many time as the loop says
function createcat($created){
    wp_insert_term($created, 'category');
}

如果我点击表单上的“提交”。我立即收到服务器错误:“HTTP错误500(内部服务器错误):服务器尝试完成请求时遇到意外情况。”

我尝试将wp_insert_terms()直接放入循环中并尝试使用wp_create_category()。如果我不包含pluggable.php,我会收到'找不到函数'的php错误。我运行了很多回声,所以我知道脚本停在wp_insert_terms()处。我试图查找服务器错误,但我的服务器没有记录任何错误。我把我的php5.ini内存增加到了20mb。我的插件及其文件夹中的所有文件都是权限755.我从其他地方安装的插件工作正常。如果我删除了wp函数,我没有得到服务器错误,页面输出最后放的回声。

也许我只是错误地构建了这个插件。任何人都可以给我的任何帮助将不胜感激!或者也许建议你如何构建插件的这一部分。

1 个答案:

答案 0 :(得分:0)

所以我查看了我的服务器日志以查看问题所在。看起来我需要包含taxonomy.php而不是pluggable.php。我必须在这个插件的末尾包含很多不同的wordpress页面。你可以在你正在阅读的函数页面底部的wordpress文档中找到每个函数调用的php页面。我想故事的道德是:500错误=看看你的服务器日志! AAAHHHH新手......

相关问题