2010-01-24 6 views

답변

2

다음 코드는 WordPress 2.9.1에서 작동합니다. 다른 버전에서도 작동하지만 2.9.1에 대해서만 테스트했습니다.

<?php 
global $wpdb; 
$post_id = get_the_ID(); 
$total_ping_count = $wpdb->get_var("SELECT count(comment_id) FROM $wpdb->comments WHERE comment_type = 'pingback'"); 
$total_approved_pings = $wpdb->get_var("SELECT count(comment_id) FROM $wpdb->comments WHERE comment_type = 'pingback' and comment_approved = 1"); 
$post_ping_count = $wpdb->get_var("SELECT count(comment_id) FROM $wpdb->comments WHERE comment_type = 'pingback' and comment_approved = 1 and comment_post_id = $post_id"); 
echo "The total number of pings on this site is $total_ping_count.\n"; 
echo "The total number of approved pings on this site is $total_approved_pings.\n"; 
echo "The total number of approved pings on this post is $post_ping_count.\n"; 
?> 

위의 코드는 pingback에 대한 계산을 제공합니다. 핑백 대신 트랙백을 원할 경우 comment_type = 'pingback'comment_type = 'trackback'으로 변경하거나 조합 된 횟수를 변경하려면 comment_type IN ('pingback', 'trackback')으로 변경하십시오.

+0

고마워. 나는 그것을 시도 할 것이다. – fatihturan