Skip Navigation

[Resolved] Query Filter – Post author is NOT the author of the page where this View…

This support ticket is created 4 years, 4 months 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by andrei-laurentiuP 4 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1411773

I am trying to Query Posts for which the author is different from the author of the page where the view is shown. Is there any way to do this?

#1412879

Hello,

There isn't such a built-in feature within Views, you might consider custom codes, for example, add below codes into your theme file functions.php:

add_filter('wpv_filter_query', function($query, $settings, $views_id){
	if($views_id == 123){
		if(isset($query['author'])){
			$author_id = $query['author'];
			unset($query['author']);
			$query['author__not_in'] = $author_id;
		}
	}
	return $query;
}, 99, 3);

Please replace 123 with your post view's ID

More help:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

#1412983

You're awesome! My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.