• Resolved Thubten

    (@thubten)


    Hello,

    For some compatibility in my theme, the get_posts function is used instead of WP_Query to list posts. I found that WP_Query is well filtered by groups but get_posts not…

    Is there a way to filter posts from get_posts function in the same way as the WP_Query function ?

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Thread Starter Thubten

    (@thubten)

    Hello,

    For the moment, the solution would be using the groups API:

    $queryProducts = get_posts(array('post_type'=> post, 'post_status'=> 'publish', 'showposts' => 1000));
    
    $user_ID = get_current_user_id();
    
    foreach ($queryProducts as $post) {
    	if (!Groups_Post_Access::user_can_read_post($post->ID, $user_ID)) continue;
    
    	$title 		=	get_the_title($post);
    	....
    }

    Yours

Viewing 1 replies (of 1 total)

The topic ‘get_posts is not filtered’ is closed to new replies.