<?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; counter</title>
	<atom:link href="http://wpengineer.com/tag/counter/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>Show Amount Of Posts, Pages, Categories, Tags, Comments For WordPress Themes</title>
		<link>http://wpengineer.com/38/show-amount-of-posts-pages-categories-tags-comments-for-wordpress-themes/</link>
		<comments>http://wpengineer.com/38/show-amount-of-posts-pages-categories-tags-comments-for-wordpress-themes/#comments</comments>
		<pubDate>Sat, 27 Sep 2008 18:03:47 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[counter]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[Tags]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=38</guid>
		<description><![CDATA[It looks like showing total amount of posts, pages and some other statistical values are very popular right now. I received many inquiries how to show statistical values on your front end. Following solution only works with WordPress 2.5 or higher. If you need help for a lower version, let me know in the comment [...]]]></description>
			<content:encoded><![CDATA[<p>It looks like showing total amount of posts, pages and some other statistical values are very popular right now. I received many inquiries how to show statistical values on your front end. </p>
<p>Following solution only works with WordPress 2.5 or higher. If you need help for a lower version, let me know in the comment field and I'll try to help.<br />
<span id="more-38"></span></p>
<h3>Number of posts</h3>
<pre lang="php">
$num_posts = wp_count_posts( &#039;post&#039; );
$num_posts = $num_posts-&gt;publish; //publish, draft
</pre>
<h3>Number of pages</h3>
<pre lang="php">
$num_pages = wp_count_posts( &#039;page&#039; );
$num_pages = $num_pages-&gt;publish; //publish
</pre>
<h3>Number of categories</h3>
<pre lang="php">
$num_cats  = wp_count_terms(&#039;category&#039;);
</pre>
<h3>Number of Tags</h3>
<pre lang="php">
$num_tags  = wp_count_terms(&#039;post_tag&#039;);
</pre>
<h3>Number of comments</h3>
<pre lang="php">
$num_comm  = get_comment_count();
$num_comm  = $num_comm&#091;&#039;approved&#039;&#093;; //approved, awaiting_moderation, spam, tot

// Solution 2
$num_comm2 = wp_count_comments( );
$num_comm2 = $num_comm2-&gt;approved; //approved, moderated, spam, total_comments
</pre>
<h3>Output</h3>
<p>The above syntax shows simple how to get the values without including HTML. In another example I show you all results in HTML as a list. Everybody can adjust the format to integrate in their design.</p>
<pre lang="php">
&lt;?php
$num_posts = wp_count_posts( &#039;post&#039; );
$num_posts = $num_posts-&gt;publish; //publish, draft
$num_posts = sprintf( __ngettext( &#039;%s Post&#039;, &#039;%s Posts&#039;, $num_posts ), number_format_i18n( $num_posts ) );

$num_pages = wp_count_posts( &#039;page&#039; );
$num_pages = $num_pages-&gt;publish; //publish
$num_pages = sprintf( __ngettext( &#039;%s Page&#039;, &#039;%s Pages&#039;, $num_pages ), number_format_i18n( $num_pages ) );

$num_cats  = wp_count_terms(&#039;category&#039;);
$num_tags  = wp_count_terms(&#039;post_tag&#039;);

$num_comm  = get_comment_count();
$num_comm  = $num_comm&#091;&#039;approved&#039;&#093;; //approved, awaiting_moderation, spam, total_comments
$num_comm  = sprintf( __ngettext( &#039;%s Categorie&#039;, &#039;%s Categories&#039;, $num_comm ), number_format_i18n( $num_comm ) );
$num_comm2 = wp_count_comments( );
$num_comm2 = $num_comm2-&gt;approved; //approved, moderated, spam, total_comments

echo &#039;&lt;ul&gt;&#039;;
echo &#039;&lt;li&gt;Posts: &#039; . $num_posts . &#039;&lt;/li&gt;&#039;;
echo &#039;&lt;li&gt;Pages: &#039; . $num_pages . &#039;&lt;/li&gt;&#039;;
echo &#039;&lt;li&gt;Categories: &#039; . $num_cats . &#039;&lt;/li&gt;&#039;;
echo &#039;&lt;li&gt;Tags: &#039; . $num_tags . &#039;&lt;/li&gt;&#039;;
echo &#039;&lt;li&gt;Comments: &#039; . $num_comm . &#039;&lt;/li&gt;&#039;;
echo &#039;&lt;li&gt;Comments 2: &#039; . $num_comm2 . &#039;&lt;/li&gt;&#039;;
echo &#039;&lt;/ul&gt;&#039;;
?&gt;
</pre>
<p>You can adjust the design of these lists. You can use classes or IDs. An example is in article &#8222;<a href="http://bueltge.de/summe-der-kommentare-in-wordpress/742/">Total Amount of Comments</a>&#8220; (in german language), where you can see a button with the amount of comments.<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/38/show-amount-of-posts-pages-categories-tags-comments-for-wordpress-themes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

