0815

Du musst dich anmelden um Beiträge und Themen zu erstellen. Einloggen · Registrieren

Display Total Number of Trackbacks and Pingbacks

Display the trackback/pingback count for each of your posts by first placing this code into your theme’s functions.php file:

function comment_count() {
	global $wpdb;
	$count = "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_type = 'pingback' OR comment_type = 'trackback'";
	echo $wpdb->get_var($count);
}

And then call the number for display anywhere in your theme by adding this code to the desired location:

<?php comment_count(); ?>

Alternately, in WordPress 2.7, you may display the total number of comments by inserting this code directly into your comments.php template:

<?php if(!empty($comments_by_type['comment'])) : 
	$count = count($comments_by_type['comment']);
	($count !== 1) ? $txt = "Comments" : $txt = "Comment"; 
?>
<h3><?php echo $count . " " . $txt; ?></h3>

Edit the markup as desired. Will display “” or “”, depending on the number of comments.

Source: WPengineer.com




0