我有一个客户希望每个作者档案有两页:
第一页-有用户信息,社交媒体链接等使用作者。php用于此
第二页-作者帖子列表
我已经建立了一切,我的问题是:
Is there a way to have get_author_posts_url() use a template other than author.php?
我有一个客户希望每个作者档案有两页:
第一页-有用户信息,社交媒体链接等使用作者。php用于此
第二页-作者帖子列表
我已经建立了一切,我的问题是:
Is there a way to have get_author_posts_url() use a template other than author.php?
有一个名为author_link
. 您可以使用该选项将URL更改为您想要的任何内容。
add_filter(
\'author_link\',
function ($link, $author_id, $author_nicename) {
var_dump($link, $author_id, $author_nicename); // debug
return $link; // return your modified URL
},
1,3
);
该问题没有足够的细节来支持更具体的代码。您可以使用template_include
钩子来更改加载的模板,其方式与上述代码更改URL的方式大致相同。
function author_archive_wpse_112852($template) {
if (/* not sure what your conditions are */) {
$template = get_stylesheet_directory().\'/diff-author-template.php\';
}
return $template;
}
add_filter(\'template_include\',\'author_archive_wpse_112852\');
如果有人需要解决这种问题,我发现another question on here 包含所有必要的步骤,包括本页已接受答案中的步骤。