如何在buddypress的会员档案页面上显示帖子


How to show posts on members profile page in buddypress

我使用的是最新的wordpress和buddypress版本。我想在作者简介页面上展示作者的帖子,以达到这个目的。我将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;
?>

我得到的结果是每个帖子的重复,第一个是优秀,然后是完整的帖子。我只想每个帖子的摘录都显示在会员个人资料页面上。请看这个。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 -->