【发布时间】:2020-06-28 12:23:34
【问题描述】:
有人知道如何在 bbpress 中通过用户 id 获取主题吗?
我要做的是显示指定作者创建的主题。
【问题讨论】:
有人知道如何在 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 -->
这可能是我昨天回答的这篇文章的副本:How to create Feed section in wordpress for homepage
【讨论】: