Php 运行此页面时出现Wordpress 404错误

Php 运行此页面时出现Wordpress 404错误,php,wordpress,wordpress-theming,Php,Wordpress,Wordpress Theming,我想在Wordpress的前端发一篇帖子。我在一个名为page submit.php的页面中有以下代码,虽然它工作正常,但在提交页面时,我收到404个错误,但我不知道为什么或如何跟踪问题 此页面page_submit.php显示良好,位于我的主题文件夹中 有什么建议吗 <?php get_header(); ?> <?php // Check if the form was submitted if( 'POST' == $_SERVER['REQUEST_METHOD']

我想在Wordpress的前端发一篇帖子。我在一个名为
page submit.php
的页面中有以下代码,虽然它工作正常,但在提交页面时,我收到404个错误,但我不知道为什么或如何跟踪问题

此页面
page_submit.php
显示良好,位于我的主题文件夹中

有什么建议吗

<?php get_header(); ?>

<?php

// Check if the form was submitted
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] )) {

// Do some minor form validation to make sure there is content
if (isset ($_POST['title'])) { 
    $title =  $_POST['title']; 
} else { 
    echo 'Please enter a title';
}
if (isset ($_POST['description'])) { 
    $description = $_POST['description']; 
} else { 
    echo 'Please enter the content'; 
}
$tags = $_POST['post_tags'];

// Add the content of the form to $post as an array
$post = array(
    'post_title'    => $title,
    'post_content'  => $description,
    'post_category' => $_POST['cat'],  // Usable for custom taxonomies too
    'tags_input'    => $tags, 
    'post_status'   => 'publish',           // Choose: publish, preview, future, etc.
    'post_type'     => $_POST['post_type']  // Use a custom post type     if you want to
);
wp_insert_post($post);  // Pass  the value of $post to WordPress the insert function
                        // http://codex.wordpress.org/Function_Reference/wp_insert_post

wp_redirect( home_url() ); // redirect to home page after submit

} // end IF
// Do the wp_insert_post action to insert it
do_action('wp_insert_post', 'wp_insert_post'); 
?>



<!-- New Post Form -->
<div id="postbox">
<form id="new_post" name="new_post" method="post" action="">

    <p><label for="title">Title</label><br />
    <input type="text" id="title" value="" tabindex="1" size="20" name="title"     />
    </p>
    <p><label for="description">Description</label><br />
    <textarea id="description" tabindex="3" name="description" cols="50" rows="6"></textarea>
    </p>
    <p><?php wp_dropdown_categories( 'show_option_none=Category&tab_index=4&taxonomy=category' ); ?></p>
    <p><label for="post_tags">Tags</label>
        <input type="text" value="" tabindex="5" size="16" name="post_tags" id="post_tags" /></p>
    <p align="right"><input type="submit" value="Publish" tabindex="6" id="submit" name="submit" /></p>

    <input type="hidden" name="post_type" id="post_type" value="post" />
    <input type="hidden" name="action" value="post" />
    <?php wp_nonce_field( 'new-post' ); ?>
</form>
</div>
<!--// New Post Form -->


<?php get_sidebar(); ?>

<?php get_footer(); ?>

标题

说明

标签


看起来您的POST变量是由Wordpress保留的。与其说是“标题”、“描述”和“帖子标签”,不如说是“标题”、“描述”和“帖子标签”。

谢谢,我只是尝试了一下,没有什么不同。事实上,我发现这些帖子现在也没有插入。进一步的调查显示,在不同的领域出现了错误——结束这个话题