Wordpress - 从多个作者那里获取帖子?

and*_*ndy 2 wordpress

使用允许用户相互关注的第三方插件,我们可以像这样检索被关注的用户(评论):-

<?php if (have_posts()) : ?>
        <?php global $userpro_social;

        $following = $userpro_social->following( get_current_user_id() ); //get users the current user is following
        print_r($following) ?> // print the array so we can see who we're following


        <?php $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; ?>     
        <?php query_posts( array( 'author'=> ??? , 'paged' => $paged, ) ); ?>      

        <?php while ( have_posts() ) : the_post() ?>


            <?php if ( has_post_format( 'video' )) {
                    get_template_part( 'video-post' );
                }elseif ( has_post_format( 'image' )) {
                    get_template_part( 'image-post' );
                } else {
                   get_template_part( 'standard-post' );
                }

            ?>

        <?php endwhile;?>

        <?php endif; ?>
Run Code Online (Sandbox Code Playgroud)

所以这会输出这样的东西

数组 ( [24] => 1 [1] => 1 )

即,我们正在关注 ID 为 1 和 24 的用户,是否足够简单?

我迷失的部分是这个

<?php query_posts( array( 'author'=> ??? , 'paged' => $paged, ) ); ?>
Run Code Online (Sandbox Code Playgroud)

我如何实际输出这些用户的帖子,它已经存储在数组中,所以我认为它应该很容易,但即使在阅读代码后我也无法弄清楚。

Raf*_*afH 7

如果要检索多个作者的帖子,则需要使用author__in参数

query_posts( array( 'author__in'=> array_keys($following) , 'paged' => $paged, ) );
Run Code Online (Sandbox Code Playgroud)