Info
- 19 posts
- 11 voices
- Started 4 years ago by NickBrady
- Latest reply from cldnails
Display latest post from WP
-
- Posted 4 years ago #
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 4 years ago #
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 4 years ago #
that was fast! ;-)
Very interesting, I see you're doing both things:
- Display WP posts in bbpress forums
- Display bbpress topics in WPAre these two different plugins? I guess it's one for WP and one for bbpress.
Looking forward to those plugins! ;-)
-
- Posted 4 years ago #
interesting too,
not lost display WP Comments.
-
- Posted 4 years ago #
Any update on that plugin?
-
- Posted 4 years ago #
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 4 years ago #
Fantastic Nick, worked straight out of the box. I really like the way you take arguments as well. :) Nicest addition would be a
beforeandafterso that it didn't have to be a list. -
- Posted 4 years ago #
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 4 years ago #
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 4 years ago #
Very interesting solution to display latest post from wordpress, i'll try it!
-
- Posted 4 years ago #
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 3 years ago #
ok, this plugin doesnt work with bbpress 0.9.0.2
if somebody know how to show the WP recent posts on BBPress please let me know.
thanks
Krystian -
- Posted 2 years ago #
"if WP and BBPress are sharing the same database"
And if WordPress is diferent database of the BBPress? -
- Posted 2 years ago #
No is possible?
-
- Posted 2 years ago #
For a non-shared DB, you just have to define the database instead of
$bbdb -
- Posted 2 years ago #
Could you provide more details? Excuse me, but the documentation of bbPress is very scarce and this complicates the customization of the forum.
-
- Posted 2 years ago #
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? -
- Posted 2 years ago #
WooHoo! A plugin accomplishing that has been just released:
http://bbpress.org/plugins/topic/wordpress-latest-post/ <--- in plugin repository
http://www.atsutane.net/2009/04/wordpress-inside-bbpress-part-1.html <--- author's blog with more info on usageTested it and it works well on WP 2.7.1 and bbPress 0.9.4 :)
-
- Posted 2 years ago #
I just use CarpRSS to convert RSS to html in my bbPress installation.
-
You must log in to post.