我正在使用下面的代码通过前端表单在 Wordpress 中创建一个页面。提交时,如何将用户重定向到新创建的页面?
更新:是否可以将 post_title 转换为 url 而不是页面 ID?那么像company.com/my-company这样的东西?
<?php $postTitle = $_POST['post_title'];
$post = $_POST['post'];
$submit = $_POST['submit'];
if(isset($submit)){
global $user_ID;
$new_post = array(
'post_title' => $postTitle,
'post_content' => $post,
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $user_ID,
'post_type' => 'members',
'post_category' => array(0)
);
wp_insert_post($new_post);
}
?>
<form action="" method="post">
<table border="1" width="200">
<tr>
<td><label for="post_title">Post Title</label></td>
<td><input name="post_title" type="text" /></td>
</tr>
<tr>
<td><label for="post">Post</label></td>
<td><input name="post" type="text" /></td>
</tr>
</table>
<input name="submit" type="submit" value="submit" />
</form>