<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>wpCanyon &#187; pingbacks</title>
	<atom:link href="http://wpcanyon.com/tag/pingbacks/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpcanyon.com</link>
	<description>Wordpress tutorials, articles, hacks, tricks and many more</description>
	<lastBuildDate>Thu, 10 Feb 2011 01:21:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Get Separate Count For Comments Trackbacks And Pingbacks In WordPress</title>
		<link>http://wpcanyon.com/tipsandtricks/get-separate-count-for-comments-trackbacks-and-pingbacks-in-wordpress/</link>
		<comments>http://wpcanyon.com/tipsandtricks/get-separate-count-for-comments-trackbacks-and-pingbacks-in-wordpress/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 00:01:29 +0000</pubDate>
		<dc:creator>Boba</dc:creator>
				<category><![CDATA[Tips&Tricks]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[count]]></category>
		<category><![CDATA[pingbacks]]></category>
		<category><![CDATA[separate]]></category>
		<category><![CDATA[trackbacks]]></category>

		<guid isPermaLink="false">http://wpcanyon.com/?p=212</guid>
		<description><![CDATA[A function to count comments or trackbacks or pingbacks or trackabacks and pingbacks together.]]></description>
			<content:encoded><![CDATA[<h2>The code</h2>
<p>Place the code bellow in your theme&#8217;s <strong>functions.php</strong> file.</p>
<pre class="brush: php;">
function commentCount($type = 'comments'){

	if($type == 'comments'):

		$typeSql = 'comment_type = &quot;&quot;';
		$oneText = 'One comment';
		$moreText = '% comments';
		$noneText = 'No Comments';

	elseif($type == 'pings'):

		$typeSql = 'comment_type != &quot;&quot;';
		$oneText = 'One pingback/trackback';
		$moreText = '% pingbacks/trackbacks';
		$noneText = 'No pinbacks/trackbacks';

	elseif($type == 'trackbacks'):

		$typeSql = 'comment_type = &quot;trackback&quot;';
		$oneText = 'One trackback';
		$moreText = '% trackbacks';
		$noneText = 'No trackbacks';

	elseif($type == 'pingbacks'):

		$typeSql = 'comment_type = &quot;pingback&quot;';
		$oneText = 'One pingback';
		$moreText = '% pingbacks';
		$noneText = 'No pingbacks';

	endif;

	global $wpdb;

    $result = $wpdb-&gt;get_var('
        SELECT
            COUNT(comment_ID)
        FROM
            '.$wpdb-&gt;comments.'
        WHERE
            '.$typeSql.' AND
            comment_approved=&quot;1&quot; 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 &gt; 1): 

		echo str_replace('%', $result, $moreText);

	endif;

}
</pre>
<p>Change the <strong>$oneText</strong>, <strong>$moreText</strong>, <strong>$noneText</strong> variable values to suit your needs. The percentage character (<strong>%</strong>) can be used in all of the variables and will be replaced with the number.</p>
<h2>Using the code</h2>
<pre class="brush: php;">
commentCount(); //echoes the comment count

commentCount('comments'); //same as the example on top

commentCount('pings'); //echoes number of trackbacks and pingbacks

commentCount('trackbacks'); //echoes number of trackbacks

commentCount('pingbacks'); //echoes number of pingbacks
</pre>
<p>If you know a simpler way to do this let me and the readers know in the comments. Thanks.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpcanyon.com/tipsandtricks/get-separate-count-for-comments-trackbacks-and-pingbacks-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Separating Trackbacks And PingBacks From Comments In WordPress</title>
		<link>http://wpcanyon.com/tutorials/separating-trackbacks-and-pingbacks-from-comments-in-wordpress/</link>
		<comments>http://wpcanyon.com/tutorials/separating-trackbacks-and-pingbacks-from-comments-in-wordpress/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 22:57:12 +0000</pubDate>
		<dc:creator>Boba</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[pingbacks]]></category>
		<category><![CDATA[trackbacks]]></category>

		<guid isPermaLink="false">http://wpcanyon.com/?p=136</guid>
		<description><![CDATA[Having trackbacks, pingbacks and comments all mixed up in one place can get really messy and confusing. In this tutorial we will separate trackbacks and pingbacks from comments.]]></description>
			<content:encoded><![CDATA[<p>Last week i wrote an article about <a href='http://wpcanyon.com/tipsandtricks/disable-trackbacks-and-pingbacks-in-wordpress-comments/' target='_blank'>disabling trackbacks and pingbacks in wordpress comments</a>, but today instead of disabling them we will separate them from comments. To see how it looks you can check some of my articles here on wpCanyon.</p>
<pre class="brush: php;">
&lt;?php if ($comments) : ?&gt;

	&lt;ol&gt;

	&lt;?php foreach ($comments as $comment) : ?&gt;

		&lt;li id=&quot;comment-&lt;?php comment_ID() ?&gt;&quot; class='commentItem'&gt;
			&lt;!-- THE COMMENT LAYOUT --&gt;
		&lt;/li&gt;

	&lt;?php endforeach; /* end for each comment */ ?&gt;

	&lt;/ol&gt;

&lt;?php endif; ?&gt;
</pre>
<p>Above we can see a stripped version of an ordinary comment loop which will show comments, trackbacks and pingbacks all in one place. Let&#8217;s change that.</p>
<h2>1st Step / Separating</h2>
<pre class="brush: php;">
&lt;?php if ($comments) : ?&gt;

	&lt;ol&gt;

	&lt;?php foreach ($comments as $comment) : ?&gt;

		&lt;?php
		$commentType = get_comment_type();
		if($commentType == 'comment') :
		?&gt;

			&lt;li id=&quot;comment-&lt;?php comment_ID() ?&gt;&quot; class='commentItem'&gt;
				&lt;!-- THE COMMENT LAYOUT --&gt;
			&lt;/li&gt;

		&lt;?php endif;/* end if comment check */ ?&gt;

	&lt;?php endforeach; /* end for each comment */ ?&gt;

	&lt;/ol&gt;

&lt;?php endif; ?&gt;
</pre>
<p><strong>get_comment_type</strong> is a function that returns &#8220;comment&#8221;, &#8220;trackback&#8221; or &#8220;pingback&#8221; depending what type the current <em>comment</em> is. </p>
<p>Now just copy paste the same code again and just change <em>&#8220;if($commentType == &#8216;comment&#8217;)&#8221;</em> to <em>if($commentType != &#8216;comment&#8217;)</em> which is the opposite of <em>&#8220;==&#8221;</em> and change the class from <em>&#8220;commentItem&#8221;</em> to <em>&#8220;trackbackItem&#8221;</em> so you can easily make different styles.</p>
<pre class="brush: php;">
&lt;?php if ($comments) : ?&gt;

	&lt;ol&gt;

	&lt;?php foreach ($comments as $comment) : ?&gt;

		&lt;?php
		$commentType = get_comment_type();
		if($commentType != 'comment') :
		?&gt;

			&lt;li id=&quot;comment-&lt;?php comment_ID() ?&gt;&quot; class='trackbackItem'&gt;
				&lt;!-- THE PINGS LAYOUT --&gt;
			&lt;/li&gt;

		&lt;?php endif;/* end if NOT comment check */ ?&gt;

	&lt;?php endforeach; /* end for each comment */ ?&gt;

	&lt;/ol&gt;

&lt;?php endif; ?&gt;
</pre>
<h2>2nd Step / The Layout</h2>
<p>Making the layout for pinbacks/trackbacks is very simple, there is only 1 function we are going to use, <strong>comment_author_link()</strong>. It just echoes the trackback/pingback link and that&#8217;s all we need.</p>
<pre class="brush: php;">
&lt;li id=&quot;comment-&lt;?php comment_ID() ?&gt;&quot; class='trackbackItem'&gt;
	&lt;?php comment_author_link(); ?&gt;
&lt;/li&gt;
</pre>
<p>That&#8217;s it. Styling is up to you <img src='http://wpcanyon.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p><em>Notice: The whole comments part is simplified for easier understanding of how to separate this, but you shouldn&#8217;t leave out the part where you check if the comment is awaiting moderation or comments are closed.</em></p>
<h2>Why separate?</h2>
<p>Thought about going through this before jumping into the code but i decided to put it at the end.</p>
<p>Let&#8217;s take a look at 2 screens i made.</p>
<h3>All mixed together</h3>
<p><img src='/post-images/separating_comments/bad.png' alt='bad' /></p>
<p><em>The screenshot above is taken from <a href='http://1stwebdesigner.com' target='_blank'>1stWebDesigner</a>.</em></p>
<p>The biggest problem in my opinion is that the conversation is broken and can become less useful. Another thing is that some articles can get a big amount of pings and push the comment to far down. And it doesn&#8217;t look nice, doesn&#8217;t it?</p>
<h3>Separated</h3>
<p><img src='/post-images/separating_comments/good.png' alt='good' /></p>
<p><em>The screenshot above is taken from the blog you are reading at the moment <img src='http://wpcanyon.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em></p>
<p>As you can see the conversation isn&#8217;t broken by the pings. The comment form won&#8217;t be pushed to far down if there are many pings. And it looks nice, doesn&#8217;t it? <img src='http://wpcanyon.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Let me know what you think about this.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpcanyon.com/tutorials/separating-trackbacks-and-pingbacks-from-comments-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

