wordpressbbpress

How to get topics by user id in bbpress?


is anyone know how to get topics by user id in bbpress?

what I want to do is displaying the topics that created by the specified author.


Solution

  • I'm assuming bbpress means wordpress as you tagged it for 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 -->
    

    Also this is probably a duplicate of this post, which I answered yesterday: How to create Feed section in wordpress for homepage