rockstardev
rockstardev

Reputation: 13537

Allow only certains user posts to display on a page in Wordpress?

I have two special users on my site. Let's call them user1 and user2. User 1 manages "user page 1" and user2 manages "user page 2". I want their posts to appear when I click on these links and only see their posts in Wordpress.

  1. Should I use categories for this and if so, how do I create a link to only show posts from a certain category?
  2. Do I need a module for this?
  3. If the answer is still not clear, how do I do this?

Upvotes: 0

Views: 725

Answers (3)

Mohit Bumb
Mohit Bumb

Reputation: 2493

Copy your index page loop and then change query from post_per_page query to this and you're done.

   $query = new WP_Query( 'author_name=rami' );

Upvotes: 0

Vidal Quevedo
Vidal Quevedo

Reputation: 986

You can use the get_author_posts_url() to create a link to a page listing a specific author's posts: http://codex.wordpress.org/Function_Reference/get_author_posts_url

The format of the link (if you just want to go ahead and test it in your browser first) will be http://www.yoursite.com/author/authorname.

Hope that helps!

Upvotes: 0

ronakg
ronakg

Reputation: 4212

You can use wp_qurey() function to show posts from specific authors.

Display posts by author, using author id:

$query = new WP_Query( 'author=123' );

Display posts by author, using author 'user_nicename':

$query = new WP_Query( 'author_name=rami' );

More details here - http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters

Upvotes: 2

Related Questions