<?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, Tipps, Tutorials, Plugins and Themes</description> <lastBuildDate>Wed, 28 Jul 2010 13:37:05 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=8390</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>Show Amount Of Posts, Pages, Categories, Tags, Comments For WordPress Themes</title><link>http://wpengineer.com/show-amount-of-posts-pages-categories-tags-comments-for-wordpress-themes/</link> <comments>http://wpengineer.com/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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$num_posts</span> <span style="color: #339933;">=</span> wp_count_posts<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>            
<span style="color: #000088;">$num_posts</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$num_posts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">publish</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//publish, draft</span></pre></div></div><h3>Number of pages</h3><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$num_pages</span> <span style="color: #339933;">=</span> wp_count_posts<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'page'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>     
<span style="color: #000088;">$num_pages</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$num_pages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">publish</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//publish</span></pre></div></div><h3>Number of categories</h3><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$num_cats</span>  <span style="color: #339933;">=</span> wp_count_terms<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><h3>Number of Tags</h3><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$num_tags</span>  <span style="color: #339933;">=</span> wp_count_terms<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_tag'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div><h3>Number of comments</h3><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$num_comm</span>  <span style="color: #339933;">=</span> get_comment_count<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                                             
<span style="color: #000088;">$num_comm</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$num_comm</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'approved'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//approved, awaiting_moderation, spam, tot</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Solution 2</span>
<span style="color: #000088;">$num_comm2</span> <span style="color: #339933;">=</span> wp_count_comments<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                                            
<span style="color: #000088;">$num_comm2</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$num_comm2</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">approved</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//approved, moderated, spam, total_comments</span></pre></div></div><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><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$num_posts</span> <span style="color: #339933;">=</span> wp_count_posts<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$num_posts</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$num_posts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">publish</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//publish, draft</span>
<span style="color: #000088;">$num_posts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span> __ngettext<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'%s Post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%s Posts'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$num_posts</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> number_format_i18n<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$num_posts</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$num_pages</span> <span style="color: #339933;">=</span> wp_count_posts<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'page'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$num_pages</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$num_pages</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">publish</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//publish</span>
<span style="color: #000088;">$num_pages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span> __ngettext<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'%s Page'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%s Pages'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$num_pages</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> number_format_i18n<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$num_pages</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$num_cats</span>  <span style="color: #339933;">=</span> wp_count_terms<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$num_tags</span>  <span style="color: #339933;">=</span> wp_count_terms<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_tag'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$num_comm</span>  <span style="color: #339933;">=</span> get_comment_count<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$num_comm</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$num_comm</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'approved'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//approved, awaiting_moderation, spam, total_comments</span>
<span style="color: #000088;">$num_comm</span>  <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span> __ngettext<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'%s Categorie'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%s Categories'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$num_comm</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> number_format_i18n<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$num_comm</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$num_comm2</span> <span style="color: #339933;">=</span> wp_count_comments<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$num_comm2</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$num_comm2</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">approved</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//approved, moderated, spam, total_comments</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;ul&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;Posts: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$num_posts</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;Pages: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$num_pages</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;Categories: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$num_cats</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;Tags: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$num_tags</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;Comments: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$num_comm</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;Comments 2: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$num_comm2</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div><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/" class="liexternal">Total Amount of Comments</a>&#8220; (in german language), where you can see a button with the amount of comments.<br
/><hr
/><h3>Related posts:</h3><ul><li><a
href="http://wpengineer.com/correct-pagination-with-get_posts/" rel="bookmark" title="Permanent Link: Correct Pagination with get_posts" class="liinternal">Correct Pagination with get_posts</a></li><li><a
href="http://wpengineer.com/customize-your-wordpress-feeds/" rel="bookmark" title="Permanent Link: Customize Your WordPress-Feeds" class="liinternal">Customize Your WordPress-Feeds</a></li><li><a
href="http://wpengineer.com/adding-a-private-page-into-the-navigation/" rel="bookmark" title="Permanent Link: Adding A Private Page Into The Navigation" class="liinternal">Adding A Private Page Into The Navigation</a></li><li><a
href="http://wpengineer.com/sticky-function-in-wordpress-27/" rel="bookmark" title="Permanent Link: Sticky Function in WordPress 2.7" class="liinternal">Sticky Function in WordPress 2.7</a></li><li><a
href="http://wpengineer.com/change-admin-pagination-on-posts-pages-and-comments/" rel="bookmark" title="Permanent Link: Change Admin Pagination on Posts, Pages and Comments" class="liinternal">Change Admin Pagination on Posts, Pages and Comments</a></li></ul><hr
/><p><img
style="float:left;" src="http://wpengineer.com/favicon.ico" alt="WP Engineer Favicon"/> Thanks for subscribing our feed! <a
href="http://buysellads.com/buy/detail/3646/" class="liexternal">Sponsor the WP Engineer Blog</a> and get your brand in front of several hundred users per day!<br
/> &copy; <a
href="http://wpengineer.com/" class="liinternal">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p> ]]></content:encoded> <wfw:commentRss>http://wpengineer.com/show-amount-of-posts-pages-categories-tags-comments-for-wordpress-themes/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Database Caching 21/34 queries in 0.828 seconds using disk
Object Caching 460/525 objects using disk

Served from: wpengineer.com @ 2010-07-29 13:07:59 -->