【发布时间】:2012-03-04 08:45:14
【问题描述】:
在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?
【问题讨论】: