bbPress

Simple, Fast, Elegant

bbPress support forums » Requests and Feedback

Display latest post from WP

(11 posts)
  1. Hi,

    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.

    Thanks!

    Posted 1 year ago #
  2. finalizing a plugin... it includes a sidebar function and and page function...

    http://test.klasen.us for the sidebar function

    http://test.158th.com for the main page latest forum topcis functions...

    should be all one wp plugin soon..

    Posted 1 year ago #
  3. 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! ;-)

    Posted 1 year ago #
  4. interesting too,

    not lost display WP Comments.

    Posted 1 year ago #
  5. Any update on that plugin?

    Posted 1 year ago #
  6. Hi,

    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?

    Thanks!

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

    
    <?php
    /*
    Plugin Name: WP Posts
    Plugin URI: http://thesandbox.wordpress.com
    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: http://thesandbox.wordpress.com
    
    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: http://codex.wordpress.org/Template_Tags/get_posts
    
    */
    
    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\\";
    	}
    }
    ?>
    
    Posted 1 year ago #
  7. 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.

    Posted 1 year ago #
  8. 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.

    Posted 1 year ago #
  9. 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'];
    	}
    }
    Posted 1 year ago #
  10. Very interesting solution to display latest post from wordpress, i'll try it!

    Posted 12 months ago #
  11. 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!

    Posted 10 months ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.