代码之家  ›  专栏  ›  技术社区  ›  coolsaint Christian C. Salvadó

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

  •  1
  • coolsaint Christian C. Salvadó  · 技术社区  · 15 年前
    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');
    

    功能。php

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

    1 回复  |  直到 15 年前
        1
  •  0
  •   matiasf    15 年前

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

    这个 get_users_of_blog() 函数将生成一个包含用户名、用户id等的对象数组。鉴于您的博客/主题支持my_博客。com/authors/AUTHOR\u ID这是可能的,但我宁愿使用 this plugin

    推荐文章