如何在 bbpress 中通过用户 ID 获取主题?
How to get topics by user id in bbpress?
有人知道如何在 bbpress 中通过用户 ID 获取主题吗?
我要做的是显示指定作者创建的主题。
我假设 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 -->
另外这可能是这个 post 的重复,我昨天回答了:
有人知道如何在 bbpress 中通过用户 ID 获取主题吗?
我要做的是显示指定作者创建的主题。
我假设 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 -->
另外这可能是这个 post 的重复,我昨天回答了: