Total Pingbacks, Trackbacks within Admin Post Columns

Snippets by IsItWP

WordPress dashboard shows many stats for your website. You can also add custom values like total pingbacks, trackbacks within admin post columns.

Instructions: Add the following code to the functions.php file of your WordPress theme. It’ll add a new column called ‘Counts’ within the admin post listing. This column will show the total number of pingbacks, trackbacks for each post.

function commentCount($type = 'comments'){

	if($type == 'trackbacks'):
		$typeSql = 'comment_type = "trackback"';
		$oneText = 'One :trackback';
		$moreText = '% :trackbacks';
		$noneText = 'No :trackbacks';
	elseif($type == 'pingbacks'):
		$typeSql = 'comment_type = "pingback"';
		$oneText = 'One :pingback';
		$moreText = '% :pingbacks';
		$noneText = 'No :pingbacks';
	global $wpdb;
    $result = $wpdb->get_var('
            '.$typeSql.' AND
            comment_approved="1" AND
            comment_post_ID= '.get_the_ID()
	if($result == 0):
		echo str_replace('%', $result, $noneText);
	elseif($result == 1):
		echo str_replace('%', $result, $oneText);
	elseif($result > 1):
		echo str_replace('%', $result, $moreText);

add_filter('manage_posts_columns', 'posts_columns_counts', 1);
add_action('manage_posts_custom_column', 'posts_custom_columns_counts', 1, 2);

function posts_columns_counts($defaults){
    $defaults['wps_post_counts'] = __('Counts');
    return $defaults;
function posts_custom_columns_counts($column_name, $id){
	if($column_name === 'wps_post_counts'){
		commentCount('trackbacks'); echo "<br />";

You may also enjoy adding post ID column to admin posts list.

Comments   Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!