WordPress重定向总是重定向到404


WordPress redirect always redirects to 404

在functions.php中,当正确的代码添加到主页时,我使用重定向来显示配置文件页面。它以前工作过,但自从第三方编码器添加了一些更改后,它就不再工作了。我最初添加了一个isset来删除Undefined index: post_type错误。现在没有更多的错误,但我没有被重定向到概要文件视图,而是被重定向到最后一个else语句:404。这是重定向代码:

    function my_template_redirect()
{
    global $wp;
    global $wp_query;
    if (isset($_REQUEST['post_type']))
    { 
    if ($_REQUEST['post_type']=="signup")
    {
        // Let's look for the property.php template file in the current theme
        if (have_posts())
        {
            include(TEMPLATEPATH . '/register.php');
            die();
        }
        else
        {
            $wp_query->is_404 = true;
        }
    }else if ($_REQUEST['post_type']=="viewprofile")
    {
        // Let's look for the property.php template file in the current theme
        if (have_posts())
        {
            include(TEMPLATEPATH . '/viewprofile.php');
            die();
        }
        else
        {
            $wp_query->is_404 = true;
        }
    }
}
    }

纵断面图代码如下:http://pastebin.com/1Nkxp0Zv。家里的表格代码是:

<div class="container">
                    <form action="<?php echo get_option('home'); ?>/?post_type=viewprofile" method="post">
                    <span>Enter your code here:</span><input name="enterCodeId" type="text" class="inputBox" /><input type="submit" value="GO!" class="go" />
                    </form>
              </div>

有什么想法吗?为什么我的钥匙不再被接受,并通过最后一个else语句继续获得404 ed?

看起来唯一的方法是不发布任何帖子,或者如果have_posts()函数返回了一个错误的值。这就是你会发现错误的地方。