簡體   English   中英

如何在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 -->

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM