简体   繁体   中英

How to show posts on members profile page in buddypress

I am using latest wordpress and buddypress version. I want to show author's post on authors profile page, to attain this. I copied members/single/profile.php to mytheme/buddypress/members/single/profile.php

Then I add this code snippet after

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;
?>

The result I am getting is repeatation of each post, 1st as exceprt and then full post. I just want excerpt of each post been shown on members profile page. Please see this. http://bit.ly/1mEbj0G

I am using latest wordpress and buddypress version.

If it's the buddypress members individual profile page you'll want to put it here..

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

Here's a stripped down version of what I'm using..

<?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 -->

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM