繁体   English   中英

在wp_insert_post上获得500(内部服务器错误)

[英]Getting 500 (Internal Server Error) on wp_insert_post

我需要一些帮助,我试图用htmlform(php和wordpress)做一个wp_insert_post 我一直收到500服务器错误,我不明白为什么,你能帮我吗? (印刷品和回声用于测试一些东西)。

 <?php print_r($_POST); if( 'POST' == $_SERVER['REQUEST_METHOD'] ){ print((isset ($_POST['title1']))); // Do some minor form validation to make sure there is content if (isset ($_POST['title1'])) { $title = $_POST['title1']; } else { echo 'fyll i'; } if (isset ($_POST['description'])) { $description = $_POST['description']; } else { echo 'fyll i'; } if (isset ($_POST['message'])) { $message = $_POST['message']; } else { echo 'fyll i'; } $tags = $_POST['post_tags']; echo('ny entry'); print_r($new_post); $new_post = array( 'post_title' => $title, 'post_content' => $message, 'post_name' => $description, 'post_status' => 'publish', 'post_type' => 'omdmen' ); print_r($new_post); $new_post = wp_insert_post($new_post); } echo('finished'); ?> 
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title></title> </head> <body> <div id="postbox"> <form id="new_post" name="new_post" method="post" action="votepost.php"> <p><label for="title">Ide</label><br /> <input type="text" id="title" value="" tabindex="1" size="20" name="title1" /> </p> <p><label for="description">Hantverk</label><br /> <input type="text" id="description" value="" tabindex="1" size="20" name="description" /> </p> <p><label for="message">Budskap</label><br /> <input type="text" id="message" value="" tabindex="1" size="20" name="message" /> </p> <input type="submit" value="OK" tabindex="6" id="submit" name="submit" /> </form> </div> </body> </html> 

$ title,'post_content'=> $ message,'post_name'=> $ description,'post_status'=>'publish','post_type'=>'omdmen'); 的print_r($ new_post); $ new_post = wp_insert_post($ new_post); echo('finished'); ?>

代码中其他位置的$ title,$ description是否已启动? 当代码到达'$ new_post = array'行时,变量可能不存在。

如果您在代码顶部设置变量,会发生什么情况:

$title = 'This is my title';
$message = 'This is my message';
$description = 'This is my description';

它得救了吗?

暂无
暂无

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

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