我对作者的模板有问题。它工作得很好,可以按预期显示作者配置文件,但问题是,只需在URL(www.mysite.com/author/subscribername)中替换用户名,就可以看到非作者配置文件(贡献者/订阅者,基本上是所有注册用户,包括和管理员)。
有没有简单的方法来修复它,只显示“作者”的个人资料,并为其他人返回“未找到页面”?
在您的支持之前,谢谢您。
Update:我已经申请并将使用的解决方案(除非有人建议如何修改初始查询)。这将返回正确的“未找到页面”页面,包括“未找到页面”页面标题:
function tb_author_role_template( $templates=\'\' )
{
global $wp_query;
$author = get_queried_object();
$role = $author->roles[0];
if($role == \'author\')
{
$templates=locate_template(array("author.php",$templates),false);
} else { // error if not author
header( \'HTTP/1.0 404 Not Found\' );
$templates = locate_template(array("404.php",$templates),false);
$wp_query->is_404 = true;
}
return $templates;
}
add_filter( \'author_template\', \'tb_author_role_template\' );