Hi Andy,
O.K. now I have an output.
Have a look at http://www.gpaed.de/g-comments
But I have two problems.
1. I have no access to the post title and the post url, which should be on top of the comment content.
2. I don't want to display the whole comment, just a few words?
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 5|;
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 { latest_wordpress_comments => \@loop }
}
<%loop latest_wordpress_comments%>
<p><a href="<%guid%>"><%comment_content%></a><br />
<%endloop%>
Matthias
gpaed.de
O.K. now I have an output.
Have a look at http://www.gpaed.de/g-comments
But I have two problems.
1. I have no access to the post title and the post url, which should be on top of the comment content.
2. I don't want to display the whole comment, just a few words?
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 5|;
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 { latest_wordpress_comments => \@loop }
}
Code:
<%latest_wordpress_comments%> <%loop latest_wordpress_comments%>
<p><a href="<%guid%>"><%comment_content%></a><br />
<%endloop%>
Matthias
gpaed.de