No doubt that WordPress is one of the most widely used blogging and CMS tool, this blog to runs on WordPress, in actual WordPress comes with a very basic comments system that’s why most blogs go for another commenting system like Disqus.

Disqus is very popular and nice commenting system but there is one problem that it do not display WordPress’s trackbacks and pinback which is one of the essential element for SEO juice.

If you too using Disqus and looking for getting trackbacks and pingback back then you will be happy to listen that in actual we can call for Track and Ping backs from WordPress database.

Pingbacks_And_Trackbacks_with_Disqus

All you have to do is open your functions.php and paste following code in it :-

 
function TA_display_pings_under_disqus() {
           // Skip if Disqus is not installed

            if(!dsq_is_installed()) return;
$current_post_ID = get_the_ID();

global $wpdb;

$sql =  "SELECT comment_author_url, comment_date, comment_content, comment_author FROM $wpdb->comments WHERE comment_post_ID = $current_post_ID AND comment_approved = '1' AND (comment_type = 'pingback' OR comment_type = 'trackback') ORDER BY comment_date ASC";

if ($post_pingtrackbacks = $wpdb->get_results($sql) ) {

$number_of_pingtrackbacks = count($post_pingtrackbacks);

if ($number_of_pingtrackbacks == 1) {
echo "<div id='pingtrackback'><h3 style='font-size:16px;margin-bottom:10px'>One Pingback/Trackback</h3><ul>";
} else {
echo "<div id='pingtrackback'><h3 style='font-size:16px;margin-bottom:10px'>" . $number_of_pingtrackbacks . " Pingbacks/Trackbacks</h3><ul>";
}

foreach ($post_pingtrackbacks as $post_pingtrackback) {

echo "<strong>";
echo date( 'd F Y at g:ma', strtotime( $post_pingtrackback->comment_date ));
echo "</strong><br>";
$comment_summary = $post_pingtrackback->comment_content;
echo substr( $comment_summary, 0, strrpos( substr( $comment_summary, 0, 90), ' ' ) ) . ' ...';

echo "n<li><a href='";
echo $post_pingtrackback->comment_author_url;
echo "'>";
$author = $post_pingtrackback->comment_author;
echo html_entity_decode($author);
echo "</a>";
echo "</li>";
}
echo "</ul></div>";
}
}

add_filter('comments_template', 'TA_display_pings_under_disqus', 1);

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.