WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] get the author posts url link of Author Archive Page in WordPress (3 posts)

  1. coolsaint
    Member
    Posted 3 years ago #

    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 under my current theme.

    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?

  2. MichaelH
    Member
    Posted 3 years ago #

    <?php
    //echo "<pre>"; print_r($wp_query->query_vars); echo "</pre>";
    $author = get_query_var('author');
    echo get_author_posts_url( $author );
    ?>
  3. coolsaint
    Member
    Posted 3 years ago #

    Thanks Michael. It worked.

Topic Closed

This topic has been closed to new replies.

About this Topic