How to display data based on author/user slug

I am creating a membership site which allow other member to view other user profile. Each user are able to add post (which I already did) but the issue is displaying the post based on the user.

<?php
    $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
    $author_query = array('post_type' => 'articles', 'posts_per_page' => '-1', 'author' => $curauth->ID);
    $author_posts = new WP_Query($author_query);
    while ($author_posts->have_posts()) : $author_posts->the_post();
        ?>

        <li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
                <?php the_title(); ?>
            </a>
        </li><br/>
        <?php
        if (has_post_thumbnail()) :
            the_post_thumbnail('medium');
        endif;
    endwhile;
?>

What happen is it will only display the post of the current logged user but what I would like it happen is display the article of the member on public and the post they made.
e.g.

domain.com/pedro

 Article 1

 Article 2

domain.com/felipe

Article 3

Article 4

Related posts

1 comment

  1. Add author.php page in your theme (if already exist then ignore).

    then your URL will look like
    http://example.com/author/hallmark/

    Where hallmark is the username and this page (author.php) is already having the code to get the posts of specific user.

    You can get the author URL as <a href="<?php echo site_url().'/?author='.USERID;?>" > See all Posts of this Author </a>

Comments are closed.