Skip Navigation

[Resolved] How to add a "filter" to filter posts by user

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by djmhimD2251 6 years ago.

Assisted by: Minesh.

Author
Posts
#1150078

Hello all,
Hope you all are doing well.
I have added filters in website but want to add filter by authors (Only those, who wrote posts there) also.

For example, please see the liink hidden link

Here, I am filtering by "Study mode" but I want filter by "Universities" also. University is a user type in website.

I tried a lot but not getting any solution at all. Please check..

Thanks a lot in advance.

#1150414

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - as I understand - you have post view and you want to filter the post view with user custom field - If this is correct. This is not supported as you can not bind post query and user query.

You can filter your view by post author:
=> https://toolset.com/documentation/user-guides/filtering-views-query-by-author/

You can not add the filter to user view but there is a different way you can add static filters - please check the following link:
=> https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/

#1150551

I think, you didn't got me
At the link, visitor can filter by a field of post which is "Study mode". Same like that, I want another drop down also for visitors, to filter by author... No custom filed of user, nothing nothing nothing else at all.. I just want drop down of authours, where visitor can select same like "Study mode"

#1150559

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - I understand now.

There is currently no built-in way to display an Author filter with custom search View.

You can refer to the following tickets for the workaround - that may need adjustment to your filters and how your filter your view:
=> https://toolset.com/forums/topic/author-frontend-filtering-with-views-and-ajax/
=> https://toolset.com/forums/topic/include-a-select-filter-with-all-authors-how-to-filter-posts-by-author/
=> https://toolset.com/forums/topic/parametric-search-by-author/

#1156822

Hello Minesh
Thanks for your reply
I tried all but not working properly.
I mean, I click on username from dropdown but then it come to all again.
I am using code as below

Function.php
_________________
add_shortcode("list-of-authors", "list_of_authors");
function list_of_authors() {
$out = '<option value="">All</option>';
$users = get_users();
foreach ($users as $user) {
$out .= '<option value="' . $user->ID . '">' . $user->display_name . '';
}
return $out;

In shortcode
________________________
<select name="author-filter" class="js-wpv-filter-trigger">[list-of-authors]</select></div>

Please have a look, thanks