如何按author id而不是像author slug那样显示authors归档
http://example.com/author/author_slug/
至http://example.com/author/123/
如何按author id而不是像author slug那样显示authors归档
http://example.com/author/author_slug/
至http://example.com/author/123/
在对作者的wp重写规则进行调查后,在@马克·戴维森的帮助下,一切都正常工作,完美的作者档案分页和rss订阅等。
下面是我创建并粘贴在这里以帮助他人的代码,感谢Mark Davidson提供的模式。
// add our custom rewrite rules for author archives
add_action(\'author_rewrite_rules\', \'my_author_rewrite_rules\');
function my_author_rewrite_rules() {
$author_rules[\'author/([0-9]+)/?$\'] = \'index.php?author=$matches[1]\';
$author_rules[\'author/([0-9]+)/page/?([0-9]{1,})/?$\'] = \'index.php?author=$matches[1]&paged=$matches[2]\';
$author_rules[\'author/([0-9]+)/(feed|rdf|rss|rss2|atom)/?$\'] = \'index.php?author=$matches[1]&feed=$matches[2]\';
$author_rules[\'author/([0-9]+)/feed/(feed|rdf|rss|rss2|atom)/?$\'] = \'index.php?author=$matches[1]&feed=$matches[2]\';
return $author_rules;
}
此函数将完全替换author重写规则,如果任何人想要添加新规则而不想替换现有规则,则他/她需要在函数like中提供$author\\u rules参数。function my_author_rewrite_rules($author_rules) {
// new rules here
}
您可以使用以下重写规则来完成此操作(您需要将其添加到functions.php
add_rewrite_rule(
\'author/([0-9]+)/?$\',
\'index.php?author=$matches[1]\',
\'top\'
);
请注意,您可能需要刷新您的规则,使其变为活动状态。你可以用rewrite plugin.我正在使用带有用户链接的wp usersonline插件,当你点击订阅服务器时,它会转到一个找不到的页面,但对作者来说效果很好,我想有没有办法将订阅服务器重定向到配置文件页面并将链接改为http://domain.com/member/profile=ID.我发现一些脚本将重定向到特定的url,但我不知道下一步该怎么做?function new_author_base() { global $wp_rewrite; $author_slug = \'profile\';&#