PDA

View Full Version : Display Recent Comments


garryconn
May 2nd, 2007, 05:18
Hello everyone. I do appologize if this question was already covered. If that is the case, if you point me in the right direction that would be great!

I have been running TripleK2 from JohnTP.com. The theme works great and does everything I need.

However, I want to create a php module for displaying recent comments. I know that there is a module already there, but it doesn't allow me to add to the code.

So, basically what I am asking is this:

What is the php code that you would manually insert into the sidebar to display the most recent comments?

Thanks in advanced for your support.

Best Regards,
Garry Conn

blogan
May 2nd, 2007, 05:42
You shouldn't need to input the PHP code directly. You should be able to use K2 Sidebar Modules to add a Recent Comments module.

If you want something with a little more configuration capability, I recommend Fresh Comments (http://beconfused.com/blog/2006/04/14/an-enhanced-recent-comments-widget-for-wordpress-call-fresh-comments/).

garryconn
May 2nd, 2007, 05:49
Thanks, I am aware of that.

To keep a long story short, what would be the php code that is written to produce the recent comments being displayed on the sidebar?

I don't need anything major... I just want to add a new php module and paste the recent comments php code into it. From there I want to add a few of my own design bells and whistles.

The standard Recent Comments Module doesn't allow me to add any additional code in the box.

Where as with a blank php module I can go ahead and add the recent comments php code into it and also add more...

See what I am saying?

So, basically the only thing I need is the php code to display recent comments.

blogan
May 2nd, 2007, 05:56
You can download the Recent Comments plugin, and look at the PHP directly.

garryconn
May 2nd, 2007, 06:04
Which recent comments plugin do I need to download to review the code?

Isn't there a code that is like the code to add most recent posts and archives such as this code below:

<?php wp_get_archives('type=monthly&limit=20&format=html '); ?>


what is the php code that is written to make the most recent comments to be displayed?

http://garryconn.com/wp-content/manual-code-comments.PNG

blogan
May 2nd, 2007, 06:09
There's probably a ton of recent comment type plugins out there. Here's one (http://www.g-loaded.eu/2006/01/15/simple-recent-comments-wordpress-plugin/). Choosing the non-widgetized version will make your study easier.

garryconn
May 2nd, 2007, 06:37
I found one code that seems like it would have worked but it doesn't:

<p>&lt;ul class="latestactivity"&gt; &lt;?php blc_latest_comments(); ?&gt; &lt;/ul&gt;</p>

blogan
May 2nd, 2007, 06:55
blc_latest_comments() has multiple arguments. Even if you enter them correctly, I don't know if this will work. K2 will need to know that blc_latest_comments() exists and I don't know how to make sure that happens without using it as a standard sidebar widget/module.

We're long past exceeding my knowledge on this issue... :o

marinegirl
May 2nd, 2007, 10:03
Try this:


<a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e('RSS Feed for all Comments','k2_domain'); ?>" class="feedlink"><img src="<?php bloginfo('template_directory'); ?>/images/feed.png" alt="RSS" /></a>
<?php

if(function_exists('blc_latest_comments')) {
?>
<ul>
<?php blc_latest_comments(sbm_get_option('num_posts'), sbm_get_option('num_comments'), sbm_get_option('hide_trackbacks'), "<li class='alternate'>", '</li>', true, 10, sbm_get_option('new_color'), sbm_get_option('old_color')); ?>
</ul>
<?php
} else {
$num_comments = sbm_get_option('num_comments');
$sql = "SELECT comment_ID, comment_post_ID, comment_author, comment_author_url FROM $wpdb->comments WHERE comment_approved = '1' ";

if(sbm_get_option('hide_trackbacks') == true) {
$sql .= "AND comment_type = '' ";
}

$sql .= "ORDER BY comment_date_gmt DESC LIMIT $num_comments";
$comments = $wpdb->get_results($sql);

if($comments) {
?>
<ul>
<?php foreach($comments as $comment): ?>
<li><?php printf(__('%1$s %2$s <a href="%3$s#comment-%4$s">%5$s</a>', 'k2_domain'), get_comment_author_link(), __('on post', 'k2_domain'), get_permalink($comment->comment_post_ID), $comment->comment_ID, get_the_title($comment->comment_post_ID)); ?></li>
<?php endforeach; ?>
</ul>
<?php
} else {
?>
<p><?php _e('No comments', 'k2_domain'); ?></p>
<?php
}
}

garryconn
May 3rd, 2007, 12:37
I get this error:


Parse error: syntax error, unexpected '<' in /home/garrycon/public_html/wp-content/themes/TripleK2/app/modules/php.php(7) : eval()'d code on line 34

--------------------------------------------------------------------------------

navai
May 4th, 2007, 09:56
You can download the Recent Comments plugin, and look at the PHP directly.

where i can do it , tell me please

blogan
May 4th, 2007, 11:02
Actually, for Recent Comments, it's already in your K2 installation at wp-contents/themes/k2/app/modules/recent_comments.php.

I meant to say Fresh Comments in what you quoted. To look at the php for that, just search on the internet for "wordpress plugin fresh comments". Download the plugin and look at it in a text editor.