【问题标题】:How to get topics by user id in bbpress?如何在 bbpress 中通过用户 id 获取主题?
【发布时间】:2020-06-28 12:23:34
【问题描述】:

有人知道如何在 bbpress 中通过用户 id 获取主题吗?

我要做的是显示指定作者创建的主题。

【问题讨论】:

    标签: wordpress bbpress


    【解决方案1】:

    我假设 bbpress 表示 wordpress,因为您将其标记为 wordpress:

    <!-- Start page loop here -->
    <?php
    // 'post_type' => 'any' ... to display all post and custom post type related to the author or user
    // You should restrict the number of post, you don't want your site crashing by loading all posts available
    // I'm letting your imagination take over
    $authID = get_the_author_meta( 'ID' );
    $query = new wp_query( array( 'author' => $authID,'post_type' => 'any', 'post_status' => 'publish', 'posts_per_page' => '3' ) );  if ( $query->have_posts() ): ?>
    <h4>Discover your feed ?</h4>
    <?php while ( $query->have_posts() ): $query->the_post(); ?>
    <!-- Start page template here -->
    <div><a aria-label="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
    <!-- End page template here -->
    <?php endwhile; else: ?>
    <h4>Your feed is empty ?</h4>
    <?php endif; ?>
    <!-- End page loop here -->
    

    这可能是我昨天回答的这篇文章的副本:How to create Feed section in wordpress for homepage

    【讨论】:

    • 感谢我从来没有想过它是否能够使用 wp_query,并且只知道他们也在使用它。这也可能对将来的任何人有所帮助pastebin.com/VHBd0uwh
    猜你喜欢
    • 1970-01-01
    • 2014-10-22
    • 1970-01-01
    • 2010-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-27
    • 1970-01-01
    相关资源
    最近更新 更多