$following_ids = bp_get_following_ids( array( 'user_id' => $user_id ) );
Thanks but it is not working what i am trying to do is i want to show post by the user current logged-in user is following
this is the code but it is not working
<?php
// Run WP_Query
// change posts_per_page value to limit the number of posts
$per_page = 8;
$following_ids = bp_get_following_ids( array( 'user_id' => $user_id ) );
$args = array(
'author__in' => $following_ids,
'posts_per_page' => $per_page,
'orderby' => 'meta_value',
'meta_key' => '_post_like_count',
'orderby' => 'meta_value_num',
'order' => 'DESC',
);
$query = new WP_Query( $args );
//begin loop
while ($query->have_posts()) : $query->the_post(); ?>
Am i doing something wrong with respect to the argument
Are you setting the $user_id? Also you are not passing the following id’s into the query, you can use the author
parameter for that, you may need to restructure the following id’s into the right format for the query. Not sure what you are doing with the meta query.
What i want to do is i want to show all the blog post by only those user , the current user is following
I’d try something like this:
<?php
// Run WP_Query
// change posts_per_page value to limit the number of posts
$per_page = 8;
$following_ids = bp_get_following_ids( array( 'user_id' => $user_id ) );
$args = array(
'author__in' => $following_ids,
'posts_per_page' => $per_page,
'author' => $following_ids
);
$query = new WP_Query( $args );
//begin loop
while ($query->have_posts()) : $query->the_post(); ?>
@venutius I have tried it is not working
Finally done we were doing wrong with respect to the $following_ids = bp_get_following_ids( array( 'user_id' => $user_id ) );
rather than passing $user_id
we should have passed this bp_loggedin_user_id()
but thanks @venutius for your help.