开发者

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

开发者 https://www.devze.com 2023-01-23 02:58 出处:网络
function fix_canonical() { global $paged; if (is_category()) { $catid = get_query_var(\'cat\'); echo \' <link rel=\"canonical\" href=\"\'.get_category_link($catid).\'\" />
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

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 author开发者_如何学运维s. 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.)

The get_users_of_blog() function will yield an array of objects containing user_name, user_id and so forth. Given that your blog/theme supports my_blog.com/authors/AUTHOR_ID this would be possible, but I'd rather use this plugin

0

精彩评论

暂无评论...
验证码 换一张
取 消