Send this to a friend
1 <ul>
2 <?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
3 foreach ($result as $post) {
4 setup_postdata($post);
5 $postid = $post->ID;
6 $title = $post->post_title;
7 $commentcount = $post->comment_count;
8 if ($commentcount != 0) { ?>
9 <li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>">
10 <?php echo $title ?></a> {<?php echo $commentcount ?>}</li>
11 <?php } } ?>
12 </ul>
<ul>
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>">
<?php echo $title ?></a> {<?php echo $commentcount ?>}</li>
<?php } } ?>
</ul>
Send this to a friend
paste the function in function.php file and call in you template with:
<?php echo ‘’.getShortUrl(get_permalink($post→ID)).‘“>short url’; ?>
1 function getShortUrl($url) {
2 $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
3 return $tinyurl;
4 }
function getShortUrl($url) {
$tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
return $tinyurl;
}
Send this to a friend
for example: save all functions in ‘your_theme/stats.php’
1 // comments_count
2 function comments_count() {
3 global $wpdb;
4 $count = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'";
5 echo $wpdb->get_var($count);
6 }
7 // < ?php comments_count() ?> comments
8
9 // posts_count
10 function posts_count() {
11 global $wpdb;
12 $count = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'";
13 echo $wpdb->get_var($count);
14 }
15 // <?php posts_count() ?></strong> articles
16
17 // retro_count
18 function retro_count() {
19 global $wpdb;
20 $count = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_type = 'pingback'";
21 echo $wpdb->get_var($count);
22 }
23 // < ?php retro_count() ?> pingbacks
// comments_count
function comments_count() {
global $wpdb;
$count = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'";
echo $wpdb->get_var($count);
}
// < ?php comments_count() ?> comments
// posts_count
function posts_count() {
global $wpdb;
$count = "SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'";
echo $wpdb->get_var($count);
}
// <?php posts_count() ?></strong> articles
// retro_count
function retro_count() {
global $wpdb;
$count = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_type = 'pingback'";
echo $wpdb->get_var($count);
}
// < ?php retro_count() ?> pingbacks