简体   繁体   English

在Wordpress中获取作者存档页面的作者帖子url链接

[英]get the author posts url link of Author Archive Page in Wordpress

function fix_canonical() {
    global $paged;
    if (is_category()) {
        $catid = get_query_var('cat');

        echo '
<link rel="canonical" href="'.get_category_link($catid).'" />
<meta name="description" content="'.$meta.'" />';
        if ($paged > 1) echo '
<meta name="robots" content="noindex,follow" />';
    } else {
        echo '';
    }

if (is_tag()) {
        $tagid = get_query_var('tag_id');

        echo '
<link rel="canonical" href="'.get_tag_link($tagid).'" />';
        if ($paged > 1) echo '
<meta name="robots" content="noindex,follow" />';
    } else {
        echo '';
    }
}
add_action('wp_head', 'fix_canonical');

functions.php functions.php

As you can see i have got the root permalink for the category and tag archives in the code. 如您所见,我在代码中获得了类别和标签归档的根永久链接。 Now I want to get the archive link for authors. 现在,我想获取作者的存档链接。 How can I do it? 我该怎么做?

It's possible to do this (you'd have to change the header.php/index.php in your theme. Do not fiddle with functions.php, it's automatically overwritten when Wordpress is upgraded.) 可以做到这一点(您必须在主题中更改header.php / index.php。不要弄乱functions.php,在升级Wordpress时,它会自动覆盖。)

The get_users_of_blog() function will yield an array of objects containing user_name, user_id and so forth. get_users_of_blog()函数将产生一个包含user_name,user_id等的对象数组。 Given that your blog/theme supports my_blog.com/authors/AUTHOR_ID this would be possible, but I'd rather use this plugin 鉴于您的博客/主题支持my_blog.com/authors/AUTHOR_ID,这是可能的,但我宁愿使用此插件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM