Skip to main content
Better formatting
Source Link
Pieter Goosen
  • 55.4k
  • 23
  • 115
  • 209

The authorpage is begin generated, and every post that an author has made will be shown. However I only want to show posts from a specific category (id=1). So

So basically, when you visit mysite.com/author/John

mysite.com/author/John

you should see only posts from John, with category ID=1 and and on mysite.com/author/Bob

mysite.com/author/Bob

you should see only posts from Bob, with category ID=1.

When I do this in ARCHIVEarchive.PHPphp:

            /* Start the Loop */ 
                    query_posts('cat=1');                               
                while (have_posts()) {
                    the_post();
                    get_template_part('content', get_post_format());
                }
                    

Unfortunately, when I do this, every post in category 1, will be shown on every author page...(You see Bobs and Johns posts on Johns author-page).

I have also tried this, but same results as above:

$curauth = get_userdata($row->ID);
$user_link = get_author_posts_url($curauth->ID);
$posts = get_posts(array(
                         'author' => $curauth->ID,
                         'cat' => 1
                         'posts_per_page' => -1,
                        )
                  );
$post_count = count($posts);

I have 2 questions.

1.Should I code in Archive.php or should I make the adjustments in author.php (not available in the theme).

  1. More importantly, how do I show catID=1 for every author ?

Thank you in advance...

  1. Should I code in archive.php or should I make the adjustments in author.php (not available in the theme).

  2. More importantly, how do I show catID=1 for every author ?

PS. View: View full code at: http://pastebin.com/NkZP4UJ9here

The authorpage is begin generated, and every post that an author has made will be shown. However I only want to show posts from a specific category (id=1). So basically, when you visit mysite.com/author/John you should see only posts from John, with category ID=1 and on mysite.com/author/Bob you should see only posts from Bob, with category ID=1.

When I do this in ARCHIVE.PHP:

            /* Start the Loop */ 
                    query_posts('cat=1');                               
                while (have_posts()) {
                    the_post();
                    get_template_part('content', get_post_format());
                }
                    

Unfortunately, when I do this, every post in category 1, will be shown on every author page...(You see Bobs and Johns posts on Johns author-page).

I have also tried this, but same results as above:

$curauth = get_userdata($row->ID);
$user_link = get_author_posts_url($curauth->ID);
$posts = get_posts(array(
                         'author' => $curauth->ID,
                         'cat' => 1
                         'posts_per_page' => -1,
                        )
                  );
$post_count = count($posts);

2 questions.

1.Should I code in Archive.php or should I make the adjustments in author.php (not available in the theme).

  1. More importantly, how do I show catID=1 for every author ?

Thank you in advance...

PS. View full code at: http://pastebin.com/NkZP4UJ9

The authorpage is begin generated, and every post that an author has made will be shown. However I only want to show posts from a specific category (id=1).

So basically, when you visit

mysite.com/author/John

you should see only posts from John, with category ID=1 and on

mysite.com/author/Bob

you should see only posts from Bob, with category ID=1.

When I do this in archive.php:

/* Start the Loop */ 
query_posts('cat=1');                               
while (have_posts()) {
    the_post();
    get_template_part('content', get_post_format());
}
        

Unfortunately, when I do this, every post in category 1, will be shown on every author page...(You see Bobs and Johns posts on Johns author-page).

I have also tried this, but same results as above:

$curauth = get_userdata($row->ID);
$user_link = get_author_posts_url($curauth->ID);
$posts = get_posts(array(
     'author' => $curauth->ID,
     'cat' => 1
     'posts_per_page' => -1,
    )
);
$post_count = count($posts);

I have 2 questions.

  1. Should I code in archive.php or should I make the adjustments in author.php (not available in the theme).

  2. More importantly, how do I show catID=1 for every author ?

PS: View full code here

Source Link

Use specific category for every author on author page

The authorpage is begin generated, and every post that an author has made will be shown. However I only want to show posts from a specific category (id=1). So basically, when you visit mysite.com/author/John you should see only posts from John, with category ID=1 and on mysite.com/author/Bob you should see only posts from Bob, with category ID=1.

When I do this in ARCHIVE.PHP:

            /* Start the Loop */ 
                    query_posts('cat=1');                               
                while (have_posts()) {
                    the_post();
                    get_template_part('content', get_post_format());
                }
                    

Unfortunately, when I do this, every post in category 1, will be shown on every author page...(You see Bobs and Johns posts on Johns author-page).

I have also tried this, but same results as above:

$curauth = get_userdata($row->ID);
$user_link = get_author_posts_url($curauth->ID);
$posts = get_posts(array(
                         'author' => $curauth->ID,
                         'cat' => 1
                         'posts_per_page' => -1,
                        )
                  );
$post_count = count($posts);

2 questions.

1.Should I code in Archive.php or should I make the adjustments in author.php (not available in the theme).

  1. More importantly, how do I show catID=1 for every author ?

Thank you in advance...

PS. View full code at: http://pastebin.com/NkZP4UJ9