如何在 buddypress 的会员个人资料页面上显示帖子

How to show posts on members profile page in buddypress

我正在使用最新的 wordpress 和 buddypress 版本。我想在作者个人资料页面上显示作者的 post,以实现此目的。我复制了 members/single/profile.php 到 mytheme/buddypress/members/single/profile.php

然后我在

之后添加这个代码片段
do_action( 'bp_after_profile_content' )
<?php 
$args = array( 'author' => bp_displayed_user_id(),
                'post_type' => 'post'
        );
query_posts( $args );
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content', $theme_options['post_layout'] );
endwhile; else:
echo ('no posts found so do something less amazing');
endif;
?>

我得到的结果是每个 post 的重复,第一个作为例外,然后完整 post。我只想在成员个人资料页面上显示每个 post 的摘录。请看这个。 http://bit.ly/1mEbj0G

我正在使用最新的 wordpress 和 buddypress 版本。

如果是 buddypress 成员的个人资料页面,你会想把它放在这里..

/wp-content/themes/YOURTHEME/buddypress/members/single/index.php

这是我正在使用的精简版..

<?php 
$authorID = bp_displayed_user_id();
$args = array( 'author' => $authorID, 'orderby' => 'date', 'order' => 'ASC', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
if ($loop->have_posts() ) :
?><!-- bgn if user has posts -->

<!-- bgn posts by this author -->
<?php 
while ($loop->have_posts() ) : $loop->the_post();
?>

<!-- your html -->

<?php endwhile; ?>
<!-- end lessons/posts by this author -->


<?php else : ?><!-- else show nothing -->

<!-- nothing -->

<?php endif; ?><!-- end if user has posts -->

<?php wp_reset_postdata(); ?>

<!-- end posts by this author -->