Skip to:

Display latest post from WP

  • NickBrady



    I’m setting up a bbpress forum linked to a WP blog. Is there any way I can show the latest posts of the blog in the forums sidebar?

    The forums and the blog use the same database, is there any way to get the latest posts from the database. If not, maybe reading the RSS of the blog, using a function like wp_rss() in WP.


Viewing 18 replies - 1 through 18 (of 18 total)

  • MrPapasWorld


    finalizing a plugin… it includes a sidebar function and and page function… for the sidebar function for the main page latest forum topcis functions…

    should be all one wp plugin soon..



    that was fast! ;-)

    Very interesting, I see you’re doing both things:

    – Display WP posts in bbpress forums

    – Display bbpress topics in WP

    Are these two different plugins? I guess it’s one for WP and one for bbpress.

    Looking forward to those plugins! ;-)

    interesting too,

    not lost display WP Comments.

    Any update on that plugin?




    I am writing a plugin for BBPress that shows the latest posts from WP (if WP and BBPress are sharing the same database). It’s still in development, but it already works, you just have to write

    <?php wp_show_posts(\"\" ); ?>

    in any BBpress template.

    As you will see, it works, but it has a problem: it does not show WP’s pretty URLs. I would like to call WP’s get_permalink() function, but it uses many WP functions that are not available when you’re in BBPress.

    Any advice on how to do this? Or maybe it would be easier to read WP’s RSS?


    Here goes the code of the plugin so far (if you don’t care about pretty permalinks, you can use it, it works):

    Plugin Name: WP Posts
    Plugin URI:
    Description: Get a list of WordPress posts from your bbPress (needs to be integrated with WP, sharing database)
    Author: Nick Brady
    Version: 0.1
    Author URI:

    Install Instructions:
    - If you don't have a /my-plugins/ directory in your bbpress installaltion, create it on the same level as config.php.

    - Check out:


    function wp_get_posts($args) {
    global $bbdb, $bb;

    parse_str($args, $r);
    if ( !isset($r['numberposts']) )
    $r['numberposts'] = 5;
    if ( !isset($r['offset']) )
    $r['offset'] = 0;
    if ( !isset($r['category']) )
    $r['category'] = '';
    if ( !isset($r['orderby']) )
    $r['orderby'] = 'post_date';
    if ( !isset($r['order']) )
    $r['order'] = 'DESC';

    $now = bb_current_time('mysql');

    $posts = $bbdb->get_results(
    \"SELECT DISTINCT * FROM \".$bb->wp_table_prefix.\"posts \" .
    ( empty( $r['category'] ) ? \"\" : \", \".$bb->wp_table_prefix.\"post2cat \" ) .
    \" WHERE post_date <= '$now' AND (post_status = 'publish') \".
    ( empty( $r['category'] ) ? \"\" : \"AND \".$bb->wp_table_prefix.\"posts.ID = \".$bb->wp_table_prefix.\"post2cat.post_id AND \".$bb->wp_table_prefix.\"post2cat.category_id = \" . $r['category']. \" \" ) .
    \" GROUP BY \".$bb->wp_table_prefix.\"posts.ID ORDER BY \" . $r['orderby'] . \" \" . $r['order'] . \" LIMIT \" . $r['offset'] . ',' . $r['numberposts'] );

    return $posts;

    function wp_show_posts( $args ) {
    global $bb;
    $posts = wp_get_posts( $args );
    foreach( $posts as $post ) {
    echo \"<li>n\";
    echo \"<a href='\".$bb->wp_home.\"?p=\".$post->ID.\"'>\";
    echo $post->post_title;
    echo \"</a><br/>n\";
    echo \"</li>n\";

    Fantastic Nick, worked straight out of the box. I really like the way you take arguments as well. :) Nicest addition would be a before and after so that it didn’t have to be a list.



    Hi, fel64, you can use wp_get_posts() instead of wp_show_posts() and then use a foreach loop, much like the examples in the WP Codex for the get_posts function

    You don’t mind that pretty permalinks are not being used? I think it’s a killer, let’s hope some expert can help us.

    Yup, I know that; I just meant that you could quite simply add it to the arguments you took and it’d be a nice addition. My modified code at the end.

    Yeah, it’s mildly annoying that the permalinks aren’t used, but it’s not a killer for me. I’d rather have this functionality than none. :) Thanks again for the plugin.

    function wp_show_posts( $args ) {
    global $bb;

    parse_str($args, $r);
    if ( !isset( $r['before'] ) )
    $r['before'] = "<li>n";
    if ( !isset( $r['after'] ) )
    $r['after'] = "<br />n</li>n";
    $posts = wp_get_posts( $args );
    foreach( $posts as $post ) {
    echo $r['before'];
    echo "<a href='".$bb->wp_home."?p=".$post->ID."'>";
    echo $post->post_title;
    echo "</a>";
    echo $r['after'];

    Very interesting solution to display latest post from wordpress, i’ll try it!



    Which edition of WP do you use? 2.0.4 or 2.1? The newest edition allows you to display latest post from wordpress.Just update your WP However, I have a problem too.How could I make a pluging of Audio Player into my blog? I’ve tried several times,but it said: fail to link!



    ok, this plugin doesnt work with bbpress

    if somebody know how to show the WP recent posts on BBPress please let me know.



    “if WP and BBPress are sharing the same database”

    And if WordPress is diferent database of the BBPress?

    No is possible?

    For a non-shared DB, you just have to define the database instead of $bbdb

    Could you provide more details? Excuse me, but the documentation of bbPress is very scarce and this complicates the customization of the forum.

    I’m also looking for that feature. Is there a working plugin?

    Or maybe there could be a solution which uses some kind of feed parsing to display latest posts?

    That is what I use to display latest discussions from bbPress into WordPress – just use the built-in RSS-parser. Is there something like that in bbPress?

    WooHoo! A plugin accomplishing that has been just released: <— in plugin repository <— author’s blog with more info on usage

    Tested it and it works well on WP 2.7.1 and bbPress 0.9.4 :)

    I just use CarpRSS to convert RSS to html in my bbPress installation.

Viewing 18 replies - 1 through 18 (of 18 total)
  • You must be logged in to reply to this topic.
Skip to toolbar