我试图建立一个wordpress查询从bbpress2.3.2的最后2个帖子显示在网站的主页上,我只是似乎无法掌握如何做到这一点。
我一直在DB中挖掘,但仍然找不到任何线索。
有人能给我指个方向吗?
谢谢。
BBpress将所有内容存储在wp_posts
表中,不同的post_type
。因此,如果您想获得最后2个帖子,您必须找到正确的post_type
(它可以是topic
的主题,或reply
的主题回复)。然后你只需使用Wordpress函数get_posts
:
$args = array(
'post_type' => 'reply',
'numberposts' => 2,
);
$postslist = get_posts( $args );
您可以更改想要获取的帖子的数量和类型。这样你就能得到你想要的了
如果你被阻止:http://codex.wordpress.org/Template_Tags/get_posts