Author filter for Views lets you query posts based on the author. You will be able to select posts that belong to the logged-in user, the page author or any specific user.

You can let users view only their posts, posts by a specific author, posts by authors set by URL parameter or posts by authors set by a Views shortcode attribute.

In the View Query Filter section, click on Add filter. You’ll see different filter options. Choose Post author to get to this dialog:

Views - Filter By Post Author
Views – Filter By Post Author

You can select the author of the post using the following ways.

Post author is the same as the logged in user

With this mode you can let a user view only his posts. This is useful for private sites and for listing the last posts by an user in the sidebar of his homepage, for example.

If the filter is set to use this mode and a visitor is not logged in, no posts will be shown.

Post author is…

Select the user and the View will filter by posts that belong to that user only.

Post author is the author of the current post in the loop

Use this setting when you’re creating nested Views and you want this inner View to inherit the author from the post of the parent Post View.

Post author is the author of the page where this View is shown

The author will be the same as the author of the page where the View is inserted.

Post author is set by the parent User View

Use this setting when you’re creating nested Views and you want this inner View to inherit the author from the user in the parent User View loop.

Post author is set by URL parameter

The author will be specified as an argument in the URL. This way, you control the author using the page that links to the page that includes the View.
You should select how to specify the user and enter the name of the URL argument. You can select the user by the ID or by username.

Arguments

First, choose how to select the author. You can either use the author ID or username. IDs and usernames – IDs must be numbers and usernames are log in name used by users. Then, enter the name of the URL parameter in the second argument. If you chose this mode, set the URL parameter to xxxxx and use it on a page (for example /page/) you should expect this behavior:

Using author IDs

  • /page/?xxxx=13 or /page/?xxxx[]=13 will show posts by the author whose ID is 13. If no such author exists, no posts will be shown.
  • /page/?xxxx[]=13&xxxx[]=15 will show posts by both the authors whose IDs are 13 and 15. If one exists, his posts will be listed; if none exist, no posts will be displayed.

Using author usernames

  • /page/?xxxx=John Foo or /page/?xxxx[]=John Foo will show posts by the author whose username is John Foo. If no such author exists, no posts will be shown.
  • /page/?xxxx[]=John Foo&xxxx[]=Peter Bar will show posts by both the authors whose usernames are John Foo and Peter Bar. If one exists, his posts will be listed; if none exist, no posts will be displayed.

Note that if the URL parameter is missing or empty, all posts will be listed and no author filtering is done.

Post author is set by a Views shortcode attribute

This mode lets you specify a shortcode attribute to chose users by their IDs or usernames separated by commas. Please note that this shortcode attribute must be lowercase.

Arguments

If you use this mode on a View called View Name, set the shortcode parameter to xxxx and call it as [wpv-view name=”View Name” xxxx=”yy”] you should expect the following behaviour:

Using author IDs

  • [wpv-view name=”View Name” xxxx=”13″] will show posts by the author whose Id is 13. If no such author exists, no posts will be shown.
  • [wpv-view name=”View Name” xxxx=”13, 15″] will show posts by authors whose IDs are 13 and 15. If one exists, his posts will be listed; if none exist, no posts will be displayed.

Using author usernames

  • [wpv-view name=”View Name” xxxx=”John Foo”] will show posts by the author whose username is John Foo. If no such author exists, no posts will be shown.
  • [wpv-view name=”View Name” xxxx=”John Foo,Peter Bar”] will show posts by authors whose usernames are John Foo and Peter Bar. If one exists, his posts will be listed; if none exist, no posts will be displayed.

If the shortcode parameter xxxx is missing or empty, no posts will be shown.