<?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>WP Engineer &#187; ping</title>
	<atom:link href="http://wpengineer.com/tag/ping/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Mon, 21 May 2012 22:48:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Comment And Ping Count In WordPress 2.7</title>
		<link>http://wpengineer.com/623/comment-ping-count/</link>
		<comments>http://wpengineer.com/623/comment-ping-count/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 13:20:58 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[ping]]></category>
		<category><![CDATA[trackback]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=623</guid>
		<description><![CDATA[The comment area changed a lot in WordPress 2.7. A good reason to check your comments.php and make some changes to it. Especially I like to seperate the comments from Ping- and Trackbacks. Matt shows in an excellent tutorial how to do it: Separating Pings from Comments. But I didn't like one thing in this [...]]]></description>
			<content:encoded><![CDATA[<p>The comment area changed a lot in <strong>WordPress 2.7</strong>. A good reason to check your comments.php and make some changes to it. Especially I like to seperate the <strong>comments</strong> from <strong>Ping- and Trackbacks</strong>. Matt shows in an excellent tutorial how to do it: <a href="http://sivel.net/2008/10/wp-27-comment-separation/" title="Matts Tutorial" >Separating Pings from Comments</a>. </p>
<p>But I didn't like one thing in this tutorial. To show the total count of your comments without Pings/Trackbacks, he writes following function in functions.php:<br />
<span id="more-623"></span></p>
<pre lang="php">
&lt;?php
add_filter(&#039;get_comments_number&#039;, &#039;comment_count&#039;, 0);
function comment_count( $count ) {
	global $id;
	$comments_by_type = &amp;separate_comments(get_comments(&#039;post_id=&#039; . $id));
	return count($comments_by_type&#091;&#039;comment&#039;&#093;);
}
?&gt;
</pre>
<p>This filter will assign globally of course. But in our blog right under the post title we have  the number of comments displayed. If there is no comment but for example 2 Pingbacks, it still shows 0 comments, even though Pingbacks are kind of a comment.</p>
<h3>The Solution</h3>
<pre lang="php">
&lt;?php
if ( ! empty($comments_by_type&#091;&#039;comment&#039;&#093;) ) :
    $count = count($comments_by_type&#091;&#039;comment&#039;&#093;);
    ($count !== 1) ? $txt = &quot;Comments&quot; : $txt = &quot;Comment&quot;; ?&gt;
    &lt;h3 id=&quot;comments&quot;&gt;&lt;?php echo $count . &quot; &quot; . $txt; ?&gt;&lt;/h3&gt;
</pre>
<p>The same for Pings and everything is perfect. <img src='http://wpengineer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/623/comment-ping-count/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

