Read below about related content about post+thumbnail+in+sidebar+wordpress, You can contact us to improve our contents and site quality

Get Recent Comment with Gravatar without plugin

January 24th, 2010 By WP Tricks Posted in Tips

Many WordPress User need to display Recent Comment on the sidebar or footer with Gravatar, most of them using plugin, right now I will show you how to Get Recent Comment with Gravatar without plugin. All need to do just write little bit of code and modified as many you want and you need.

On our recent article, I was cover tips to display most commented post with gravatar without plugin, and I hope you’ll enjoy this tricks too, because this trick also simple and of course useful.

Let’s get started, open your sidebar.php or footer.php or whatever files you need to display recent comment and add this code

<?php
$query = "SELECT * from $wpdb->comments WHERE comment_approved= '1'
ORDER BY comment_date DESC LIMIT 0 ,5";
$comments = $wpdb->get_results($query);

if ($comments) {
    echo '<ul>';
    foreach ($comments as $comment) {
        $url = '<a href="'. get_permalink($comment->comment_post_ID).'#comment-'.$comment->comment_ID .'" title="'.$comment->comment_author .' | '.get_the_title($comment->comment_post_ID).'">';
        echo '<li>';
        echo '<div class="img">';
        echo $url;
        echo get_avatar( $comment->comment_author_email, $img_w);
        echo '</a></div>';

        echo '<div class="txt">Par: ';
        echo $url;
        echo $comment->comment_author;
        echo '</a></div>';
        echo '</li>';
    }
    echo '</ul>';
}
?>

Read the rest of this entry »

Amazing Touch

How to Get Most Commented Posts with Thumbnail

January 10th, 2010 By WP Tricks Posted in Tricks

There are so many way to attract visitor on your WordPress blog, the one of them is show most popular post on your sidebar or footer, beside that fact in order to help your visitors finding your best content.

Let’s me share “How to get most commented posts along with their related thumbnail“, This trick need little bit code to be written on your themes files. I will show you how to do this. The first time, open your sidebar.php or footer.php or whatever files with your favorite editor. Then write down this code

<?php $popular = new WP_Query('orderby=comment_count&posts_per_page=5'); ?>
	<?php while ($popular->have_posts()) : $popular->the_post(); ?>
	<?php $justanimage = get_post_meta($post->ID, 'thumbnail', true);
		if ($justanimage) { ?>
	<img src="<?php echo get_post_meta($post->ID, "Image", true); ?>" alt="<?php the_title(); ?>" />
	<?php } else { ?>
	<img src="http://an-alternative-image.jpg" alt="" />
	<?php } ?>
	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php endwhile; ?>

Read the rest of this entry »

Amazing Touch