0

我有一个关于如何根据 WordPress 和 BBpress 标签显示相关主题的问题。我目前能够显示最新主题,但与文章无关。

<div class="bbp-related">
    <?php
        $topics_post = array('author'=> 0, 'post_type'=>bbp_get_topic_post_type(), 'post_parent'=>$parent_forum, 'posts_per_page'=>3, 'post_status'=>join(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id())), 'show_stickes'=>false, 'meta_key'=>'_bbp_last_active_time', 'orderby'=>'meta_value', 'order'=>'DESC', 'meta_query'=>array(bbp_exclude_forum_ids('meta_query')));
    ?>
    <?php $widget_query = new WP_Query($topics_post); ?>
    <?php   while ($widget_query->have_posts()) :
        $widget_query->the_post();
        $topic_id = bbp_get_topic_id($widget_query->post->ID);
    ?>
        <li>
            <?php bbp_author_link( array( 'post_id' => 1, 'size' => 100 ) ); ?>
            <a class="bbp-title" href="<?php bbp_topic_permalink($topic_id); ?>" title="<?php bbp_topic_title($topic_id); ?>"><?php bbp_topic_title($topic_id); ?></a>
            <p><?php bbp_topic_excerpt($topic_id); ?></p>
            <span class="reply"><?php bbp_forum_reply_count(); ?> Balasan</span>
            <span class="reply-date"><?php bbp_reply_post_date(0, true); ?></span>
        </li>
        <?php   endwhile; ?>
</div>

上面的代码目前显示了 3 个最新的主题。我想要的是基于标签或类别显示相关主题。我怎样才能做到这一点?谢谢

4

0 回答 0