Info
- 60 posts
- 19 voices
- Started 3 years ago by _ck_
- Latest reply from chrishajer
- This topic is not a support question
Here's how to show bbPress info inside WordPress without full integration
-
- Posted 2 years ago #
I need more info than "didn't work"
Try replacing $bbdb with $wpdb
-
- Posted 2 years ago #
I need more info than "didn't work"
Fatal error: Call to a member function get_results() on a non-object in wordpress/wp-content/themes/mytheme/header.php on line 149 (line where I placed the code)
Try replacing $bbdb with $wpdb
no error but what I want is to query bbpress data base. Whenever I echo $results there is no answer.
-
- Posted 2 years ago #
That is with bbPress 1.0 right? the object_type is for 1.0
You get nothing using get_results because it returns an array - use get_var instead
<?php global $bbdb; $result=$bbdb->get_var("SELECT SUM(meta_value) FROM bb_meta WHERE object_type='bb_topic' AND meta_key='views'"); echo $result; ?> -
- Posted 2 years ago #
That is with bbPress 1.0 right? the object_type is for 1.0
Yes, it is bb 1.06a with wp 2.7 :)
I tried with get_var and I get the same error for get_var;
Fatal error: Call to a member function get_var() on a non-object in....
but then I changed $bbdb for $wpdb and it works. Why? I don't understand this.
-
- Posted 2 years ago #
Because for some reason the bbdb object must not be created when deeply integrated under 1.0
Must have something to do with backpress which re-uses wp functions.
-
- Posted 2 years ago #
Ok, thanks for your help :) I'm going to try more of these queries. I find them very useful to integrate small details.
-
- Posted 2 years ago #
This other nice trick by you doesn't work either from the wp comments template;
global $wpdb; $result=$wpdb->get_var("SELECT COUNT(*) FROM bb_posts WHERE poster_id = $user_id AND post_status = 0"); echo $result;No errors though. I tried replacing poster_id with wp comment_author_id but it didn't make it.
What I was trying to do is to put the the whole count of wp comments and bbpress posts all together.
The previous question was because I produced a hit counter that runs for both; wp and bbpress. I added the total hits of the bbpress post views plugin to the wp counterize plugin. It works but I think I did this by the hard way.
-
- Posted 2 years ago #
Hello, so how's the code if we'd like to add posteb by... in ...
I get the topic and forums list but'd like to show the author.
Tried the codes at the beginning but doesnt seem to work, fatal errors :Sthanks in advance
ernesto
-
- Posted 2 years ago #
edlvg you want something like
echo "Posted by $result->topic_poster_name";I just realized I completely missed explaining how to get forum names via WordPress, I was telling people to use bbPress functions which is of course impossible from WordPress. Let me know if anyone still needs the help.
-
- Posted 2 years ago #
can you please just do a step by step tutorial, it is really hard to follow and i dont know which piece of code goes where.
-
- Posted 2 years ago #
thanks _ck_ worked beautiful, sounds quite helpful having a tutorial though, :p
-
- Posted 2 years ago #
Well since bbpress and wordpress are using ezsql... you can find ezsql tutorial here.
-
- Posted 2 years ago #
Hey guys! I can't make $result->topic_poster_name work in my 0.9.0.4 instalation.
Is this the right function for this version?
// REPLIES
$query_replies="SELECT * FROM bb_posts WHERE topic_id=$topic_id AND post_id != $first_reply_id AND post_status=0 ORDER BY post_time DESC";
$results_replies=$wpdb->get_results($query_replies);
$replies_text = "";foreach ($results_replies as $result) {
echo $result->post_text;
echo $result->topic_poster_name;
}
The post_text works perfectly, but the poster_name returns me nothing. Any idea?
-
- Posted 2 years ago #
Done!
get_post_author($result->post_id);
Could find in:
http://phpxref.ftwr.co.uk/bbpress/nav.html?_functions/index.html
-
- Posted 2 years ago #
Yes but that wouldn't work from the WordPress side.
The correct way to do it directly would be to either use the topic table which has the topic_poster_name (not bb_posts) or to use a LEFT JOIN on the user table to fetch the user_login.
The LEFT JOIN will also get you the display name.
But there are several problems with your question.
First of all, you mean Display Name, not Nice Name, unless you are trying to use it in a way I don't understand.Secondly 0.9 doesn't use Display Name.
Third,
"SELECT * FROM bb_posts WHERE topic_id=$topic_id AND post_id != $first_reply_id AND post_status=0 ORDER BY post_time DESC"is a very inefficient query, there's no LIMIT, you are using *
what exactly are you trying to find? -
- Posted 2 years ago #
dear _ck_,
i did as you suggested with adding
<?php require('/local-path-to-bbpress/bb-load.php'); ?>
to wordpress but it conflicts with wp-admin.
any idea how to resolve this?http://bbpress.org/forums/topic/wordpress-integration-login#post-55751
-
- Posted 2 years ago #
Tomwi: can you post your code for showing mentioned template
*post title*
Posted by: *user* in *forum*.or send it to me - procka@tasty.sk
greets
Vlado -
- Posted 2 years ago #
How does using
$wpdb&$bbdbdiffers from using$results=mysql_query($query);? -
- Posted 2 years ago #
$wpdb and $bbdb have nice sanitizing functions and caching of results if I remember correctly
http://codex.wordpress.org/Function_Reference/wpdb_Class
They can also be used to retrieve table names for the respective package -
- Posted 2 years ago #
Thanks ! I forgot that I should check out the codex for that.
-
- Posted 2 years ago #
@Kawauso
I think using$wpdb&$bbdbshould sanitize by them self but reading the page on codex it looks like that we need to do that explicitly. I am a lil confused. Can you please clarify? -
- Posted 2 years ago #
Yep, you have to sanitize yourself, the database objects presume anything they're passed has been already
-
- Posted 2 years ago #
How exactly can I exclude some forums for showing up in this code, that generates a list of forums, or rather, HOW can i show only selected forums?
<?php if ( $topic ) : ?> <h2>Forum List</h2> <ul> <?php global $bbdb; $query="SELECT * FROM bb_forums WHERE topics!=0 ORDER BY forum_order ASC LIMIT 10"; $results=$bbdb->get_results($query); foreach ($results as $result) { echo "<li><a href='/forum.php?id=".$result->forum_id."'>".$result->forum_name."</a></li>"; } ?> </ul> <?php endif; ?> -
- Posted 2 years ago #
SELECT * FROM bb_forums WHERE forum_id <> 1 AND forum_id <> 2 AND topics <> 0 ORDER BY forum_order ASC LIMIT 10
Got the idea? -
- Posted 2 years ago #
Actually I don't. I tried your code, but its still showing the same.
-
- Posted 2 years ago #
This works for me quite well. May be you are doing something wrong!
-
- Posted 2 years ago #
Can someone explain how I can pull the total number of bbpress posts made and display them in wordpress theme, and also a harder one to solve, how do I get the total number of posts for a user in bbpress and display that in the users wordpress author.php?
I've got intergration happening with shared login/registrations, tables in same DB.
Thanks for any help :)
-
- Posted 1 year ago #
Great Examples :) ... I think these examples would be great in the documentation for bbPress.
-
- Posted 1 year ago #
We might be able to guilt/nag Matt into getting a proper Wiki installed here once he gets WordPress 3 out the door (but then there will be 3.0.1 and 3.0.2 the week after, so maybe 2 weeks then, lol)
-
- Posted 1 year ago #
This is my favorite topic of all time on bbpress.org - thanks _ck_
-
You must log in to post.