【问题标题】:get the author posts url link of Author Archive Page in Wordpress在 Wordpress 中获取作者存档页面的作者帖子 url 链接
【发布时间】:2010-11-01 08:23:05
【问题描述】:
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

如您所见,我在代码中获得了类别和标签档案的根永久链接。现在我想获取作者的存档链接。我该怎么做?

【问题讨论】:

    标签: php wordpress theming


    【解决方案1】:

    可以这样做(您必须更改主题中的 header.php/index.php。不要摆弄functions.php,它会在 Wordpress 升级时自动覆盖。)

    get_users_of_blog() 函数将产生一个对象数组,其中包含 user_name、user_id 等。鉴于您的博客/主题支持 my_blog.com/authors/AUTHOR_ID 这是可能的,但我宁愿使用this plugin

    【讨论】:

    • 这是主题的functions.php文件。你可以看到我最后调用了一个动作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-11
    • 1970-01-01
    • 1970-01-01
    • 2014-08-11
    • 1970-01-01
    相关资源
    最近更新 更多