Gossamer Forum
Quote Reply
global for bbpress
Hi Andy,
pretty quiet in here ;-)
So what about a global to get the latest bbpress plugin threads?
This code below calls the latest wordpress entries. Perhabs there is not much to change for bbpress?
Code:
sub {
my $prefix = 'wp_';

use DBI;
my $dbh = DBI->connect('DBI:mysql:xxxxxxxxxxxxxxxxxxxxxxxx
) || die "Could not connect to database: $DBI::errstr";


my $query = qq|SELECT * FROM ${prefix}posts WHERE post_parent < 1 AND post_status = 'publish' AND post_type = "post" ORDER BY ID DESC LIMIT 3|;

my $sth = $dbh->prepare($query) || die $DBI::errstr;
$sth->execute() || die $DBI::errstr;

my @loop;
while (my $hit = $sth->fetchrow_hashref) {
push @loop, $hit;
}

$sth->finish();
$dbh->disconnect();

return { blog_loop => \@loop }

}

Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] global for bbpress In reply to
Hi,

Quote:
pretty quiet in here ;-)

Ya :(

Quote:
So what about a global to get the latest bbpress plugin threads?
This code below calls the latest wordpress entries. Perhabs there is not much to change for bbpress?

I'm afraid I don't have a copy of BBPress installed, so can't really guess as to what the structure looks like. I had a quick look around, to see if I could find a SQL query that would do it - but can't find anything. If you can get a working SQL query, then it should as simple as duplicating that global, and replacing the SQL query it in Angelic

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] global for bbpress In reply to
Hi Andy,
here is a thread with some infos about sql query for unanswered thread.
Don't need the unanswered thing, just newest threads ;-)
https://bbpress.org/forums/topic/query-for-thread-with-no-new-answers/

Thanks

Matthias
gpaed.de

Last edited by:

Matthias70: Jan 23, 2015, 5:47 AM
Quote Reply
Re: [Matthias70] global for bbpress In reply to
Can you send me a screenshot, with the columns in the wp_posts table, and all its columns?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] global for bbpress In reply to
Hi Andy,
I have problems to copy the whole page. My firefox addon does not regognize the whole page.
But the difference between post an thread seems just
post-type = topic instead of post

everthing else seem to be the same...

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] global for bbpress In reply to
Ah ok - well in that case, just make a new global with the same code, but change:


Code:
my $query = qq|SELECT * FROM ${prefix}posts WHERE post_parent < 1 AND post_status = 'publish' AND post_type = "post" ORDER BY ID DESC LIMIT 3|;

to

Code:
my $query = qq|SELECT * FROM ${prefix}posts WHERE post_parent < 1 AND post_status = 'publish' AND post_type = "topic" ORDER BY ID DESC LIMIT 3|;

:)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] global for bbpress In reply to
Hm, the global has no output.
Just found another difference.
Posts do have post_parent 0
and
Topics have post_parent 21000 and more...

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] global for bbpress In reply to
Try:

Code:
my $query = qq|SELECT * FROM ${prefix}posts WHERE post_parent > 21000 AND post_status = 'publish' AND post_type = "topic" ORDER BY ID DESC LIMIT 3|;

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] global for bbpress In reply to
Hey Andy, that's it :-)
Thanks

Matthias
gpaed.de