【问题标题】:Buddypress Show a members most recent post in members loopBuddypress 在成员循环中显示成员最近的帖子
【发布时间】:2013-06-15 14:31:19
【问题描述】:

在我的成员列表中,我显示了头像、用户名、个人资料数据等的标准字段 - 这一切都很好。

我还想显示该用户的“最新帖子”。

我可以使用 sn-p 来获取该作者的最新帖子吗?以某种方式确定它是哪位作者以及他们最近的帖子?

谢谢,

伊恩

【问题讨论】:

    标签: wordpress loops post buddypress author


    【解决方案1】:

    有人为此提供了一个很好的解决方案:

    <?php
    $user_id = bp_get_member_user_id(); 
    $query = new WP_Query( 'author=' . $user_id );
    
    if ( $query->have_posts() ) {
        while ( $query->have_posts() ) {
            $query->the_post();
            //display title
            the_title();
            //display content
            the_content(); ?>
    
            <a href="<?php the_permalink(); ?>">
               <img src="<?php the_field('featuredimage'); ?>" alt="" />
            </a>
       <?php }
    }
    
    //reset for next member
    wp_reset_postdata();
    ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-10
      • 1970-01-01
      • 2013-06-27
      • 2017-05-11
      • 2020-04-26
      • 1970-01-01
      • 1970-01-01
      • 2022-12-11
      相关资源
      最近更新 更多