Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Re: [Andy] Latest posts from wordpress on home.html

Quote Reply
Re: [Andy] Latest posts from wordpress on home.html In reply to
Hi Andy,
it's working fine.
test example at http://www.gpaed.de/g-comments
Just had to change post_id to ID (marked red)
Is there a way to cut off the <%comment_content%> after 50 signs?

Code:
sub {
my $prefix = 'wp_';

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

my $query = qq|SELECT * FROM ${prefix}comments ORDER BY comment_date DESC LIMIT 10|;

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

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

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

return { latest_wordpress_comments => \@loop };

sub get_title {
my $ID = $_[0];
my $sth = $dbh->prepare(qq|SELECT post_title FROM ${prefix}posts WHERE ID = $ID|) || die $DBI::errstr;
$sth->execute() || die $DBI::errstr;
return $sth->fetchrow;
}

}

Code:
<%latest_wordpress_comments%>
<%loop latest_wordpress_comments%>
<p><a href="http://www.gpaed.de/blog/?p=<%comment_post_ID%>"><%post_title%></a><br /><small><%comment_content%></small>
<%endloop%>

Thanks

Matthias
gpaed.de
Subject Author Views Date
Thread Latest posts from wordpress on home.html Matthias70 18198 Jul 20, 2008, 1:30 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Andy 17806 Jul 20, 2008, 2:36 AM
Thread Re: [Andy] Latest posts from wordpress on home.html
Matthias70 17738 Jul 20, 2008, 2:54 AM
Post Re: [Matthias70] Latest posts from wordpress on home.html
Andy 17763 Jul 20, 2008, 2:54 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Andy 17754 Jul 20, 2008, 6:30 AM
Thread Re: [Andy] Latest posts from wordpress on home.html
Matthias70 17732 Jul 20, 2008, 8:11 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Matthias70 17756 Jul 20, 2008, 8:15 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Andy 17734 Jul 20, 2008, 9:04 AM
Thread Re: [Andy] Latest posts from wordpress on home.html
Matthias70 17750 Jul 20, 2008, 9:50 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Matthias70 17768 Jul 29, 2008, 6:53 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Andy 17670 Jul 29, 2008, 7:57 AM
Thread Re: [Andy] Latest posts from wordpress on home.html
Matthias70 17739 Jul 29, 2008, 8:12 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Matthias70 17712 Oct 16, 2008, 2:30 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Andy 17692 Oct 16, 2008, 2:32 AM
Thread Re: [Andy] Latest posts from wordpress on home.html
hegu 17399 May 17, 2009, 6:54 AM
Thread Re: [hegu] Latest posts from wordpress on home.html
Andy 17405 May 17, 2009, 9:00 AM
Thread Re: [Andy] Latest posts from wordpress on home.html
Matthias70 17384 May 17, 2009, 11:55 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Andy 17420 May 17, 2009, 11:36 PM
Thread Re: [Andy] Latest posts from wordpress on home.html
Matthias70 17411 May 18, 2009, 9:54 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Andy 17387 May 18, 2009, 10:03 AM
Thread Re: [Andy] Latest posts from wordpress on home.html
Matthias70 17317 May 18, 2009, 10:32 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Andy 17365 May 18, 2009, 10:40 AM
Thread Re: [Andy] Latest posts from wordpress on home.html
Matthias70 17381 May 18, 2009, 10:57 AM
Post Re: [Matthias70] Latest posts from wordpress on home.html
Andy 17246 May 18, 2009, 11:52 PM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Andy 17304 May 18, 2009, 11:58 PM
Thread Re: [Andy] Latest posts from wordpress on home.html
Matthias70 6975 May 19, 2009, 9:51 AM
Post Re: [Matthias70] Latest posts from wordpress on home.html
Andy 6986 May 19, 2009, 9:53 AM
Thread Re: [Andy] Latest posts from wordpress on home.html
Matthias70 6980 May 19, 2009, 10:23 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Matthias70 6550 May 31, 2013, 3:50 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Andy 6513 May 31, 2013, 8:18 AM
Thread Re: [Andy] Latest posts from wordpress on home.html
Matthias70 6410 Jun 1, 2013, 1:35 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Andy 6361 Jun 1, 2013, 2:17 AM
Thread Re: [Andy] Latest posts from wordpress on home.html
Matthias70 6472 Jun 1, 2013, 2:29 AM
Thread Re: [Matthias70] Latest posts from wordpress on home.html
Andy 6366 Jun 1, 2013, 2:40 AM
Post Re: [Andy] Latest posts from wordpress on home.html
Matthias70 6394 Jun 1, 2013, 2:47 AM