<?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; post</title>
	<atom:link href="http://wpengineer.com/tag/post/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Sun, 22 Jan 2012 13:32:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>First Impressions of Custom Post Type</title>
		<link>http://wpengineer.com/1969/impressions-of-custom-post-type/</link>
		<comments>http://wpengineer.com/1969/impressions-of-custom-post-type/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 07:07:36 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress News]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[WP3.0]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1969</guid>
		<description><![CDATA[One of the new very interesting things in WordPress 3.0 are individual post-types you can implement with little effort. Back then, you had to expand the database and write your own interface for it, now you just have to add a few lines of code - of course this is just the current state, which [...]]]></description>
			<content:encoded><![CDATA[<p>One of the new very interesting things in WordPress 3.0 are individual post-types you can implement with little effort. Back then, you had to expand the database and write your own interface for it, now you just have to add a few lines of code - of course this is just the current state, which can be change until the final release.</p>
<p>After <a href="http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page">Justin had been playing with these types</a>, we check out the possibilities of types for "Movies".</p>
<h4>Simple Solution</h4>
<pre lang="php">
function post_type_movies() {
	register_post_type( &#039;movies&#039;,
                array( &#039;label&#039; =&gt; __(&#039;Movies&#039;), &#039;public&#039; =&gt; true, &#039;show_ui&#039; =&gt; true ) );
	register_taxonomy_for_object_type(&#039;post_tag&#039;, &#039;movies&#039;);
}
add_action(&#039;init&#039;, &#039;post_type_movies&#039;);
</pre>
<p><img src="http://wpengineer.com/wp-content/uploads/default-custom-post-type.png" alt="default custom post type" title="default-custom-post-type" width="450" height="373" class="aligncenter size-full wp-image-1970" /></p>
<h4>More parameters for meta-boxes</h4>
<p>Of course there are a number of parameters for this function and so the behavior and appearance of the corresponding edit page can be controlled quite easily, a small sample with additional meta boxes:</p>
<pre lang="php">
function post_type_movies() {
	register_post_type(
                     &#039;movies&#039;,
                     array(&#039;label&#039; =&gt; __(&#039;Movies&#039;),
                             &#039;public&#039; =&gt; true,
                             &#039;show_ui&#039; =&gt; true,
                             &#039;supports&#039; =&gt; array(
                                        &#039;post-thumbnails&#039;,
                                        &#039;excerpts&#039;,
                                        &#039;trackbacks&#039;,
                                        &#039;custom-fields&#039;,
                                        &#039;comments&#039;,
                                        &#039;revisions&#039;)
                                )
                      );
	register_taxonomy_for_object_type(&#039;post_tag&#039;, &#039;movies&#039;);
}
add_action(&#039;init&#039;, &#039;post_type_movies&#039;);
</pre>
<p><img src="http://wpengineer.com/wp-content/uploads/custom-post-type.png" alt="" title="custom-post-type" width="450" height="602" class="aligncenter size-full wp-image-1971" /></p>
<h4>The default arguments</h4>
<pre lang="php">
// Args prefixed with an underscore are reserved for internal use.
$defaults = array(
    &#039;label&#039; =&gt; false,
    &#039;publicly_queryable&#039; =&gt; null,
    &#039;exclude_from_search&#039; =&gt; null,
    &#039;_builtin&#039; =&gt; false,
    &#039;_edit_link&#039; =&gt; &#039;post.php?post=%d&#039;,
    &#039;capability_type&#039; =&gt; &#039;post&#039;,
    &#039;hierarchical&#039; =&gt; false,
    &#039;public&#039; =&gt; false,
    &#039;rewrite&#039; =&gt; true,
    &#039;query_var&#039; =&gt; true,
    &#039;supports&#039; =&gt; array(),
    &#039;register_meta_box_cb&#039; =&gt; null,
    &#039;taxonomies&#039; =&gt; array(),
    &#039;show_ui&#039; =&gt; null
);
</pre>
<ul>
<li><strong>label</strong> - A descriptive name for the post type marked for translation. Defaults to $post_type</li>
<li><strong>public</strong> - Whether posts of this type should be shown in the admin UI. Defaults to false</li>
<li><strong>exclude_from_search</strong> - Whether to exclude posts with this post type from search results. Defaults to true if the type is not public, false if the type is public</li>
<li><strong>publicly_queryable</strong> - Whether post_type queries can be performed from the front page.  Defaults to whatever public is set as</li>
<li><strong>show_ui</strong> - Whether to generate a default UI for managing this post type. Defaults to true if the type is public, false if the type is not public</li>
<li><strong>inherit_type</strong> - The post type from which to inherit the edit link and capability type. Defaults to none</li>
<li><strong>capability_type</strong> - The post type to use for checking read, edit, and delete capabilities. Defaults to "post"</li>
<li><strong>edit_cap</strong> - The capability that controls editing a particular object of this post type. Defaults to "edit_$capability_type" (edit_post)</li>
<li><strong>edit_type_cap</strong> - The capability that controls editing objects of this post type as a class. Defaults to "edit_ . $capability_type . s" (edit_posts)</li>
<li><strong>edit_others_cap</strong> - The capability that controls editing objects of this post type that are owned by other users. Defaults to "edit_others_ . $capability_type . s" (edit_others_posts)</li>
<li><strong>edit_others_cap</strong> - The capability that controls publishing objects of this post type. Defaults to "publish_ . $capability_type . s" (publish_posts)</li>
<li><strong>read_cap</strong> - The capability that controls reading a particular object of this post type. Defaults to "read_$capability_type" (read_post)</li>
<li><strong>delete_cap</strong> - The capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post)</li>
<li><strong>hierarchical</strong> - Whether the post type is hierarchical. Defaults to false</li>
<li><strong>supports</strong> - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none</li>
<li><strong>register_meta_box_cb</strong> - Provide a callback function that will be called when setting up the meta boxes for the edit form.  Do remove_meta_box() and add_meta_box() calls in the callback</li>
<li><strong>taxonomies</strong> - An array of taxonomy identifiers that will be registered for the post type.  Default is no taxonomies. Taxonomies can be registered later with register_taxonomy() or register_taxonomy_for_object_type()</li>
</ul>
<h4>Including Custom Taxonomies</h4>
<p>In the following example we include in our Post-Type a Taxonomy with two possibilities; own Tags and categories for Post-Type <em>Movies</em>, the classical tag, without hierarchy and one as category, tag with hierarchies.</p>
<pre lang="php">
function post_type_movies() {
	register_post_type(
                &#039;movies&#039;,
                array(
                        &#039;label&#039; =&gt; __(&#039;Movies&#039;),
                        &#039;public&#039; =&gt; true,
                        &#039;show_ui&#039; =&gt; true,
                        &#039;supports&#039; =&gt; array(
                                     &#039;post-thumbnails&#039;,
                                     &#039;excerpts&#039;,
                                     &#039;trackbacks&#039;,
                                     &#039;custom-fields&#039;,
                                     &#039;comments&#039;,
                                     &#039;revisions&#039;)
                )
        );

	register_taxonomy( &#039;actor&#039;, &#039;movies&#039;, array( &#039;hierarchical&#039; =&gt; true, &#039;label&#039; =&gt; __(&#039;Actor&#039;) ) ); 

        register_taxonomy( &#039;production&#039;, &#039;movies&#039;,
		array(
                         &#039;hierarchical&#039; =&gt; false,
			 &#039;label&#039; =&gt; __(&#039;Production&#039;),
			 &#039;query_var&#039; =&gt; &#039;production&#039;,
			 &#039;rewrite&#039; =&gt; array(&#039;slug&#039; =&gt; &#039;production&#039; )
		)
	);
}
add_action(&#039;init&#039;, &#039;post_type_movies&#039;);
</pre>
<p><img src="http://wpengineer.com/wp-content/uploads/taxonomy-custom-post-type.png" alt="" title="taxonomy-custom-post-type" width="450" height="385" class="aligncenter size-full wp-image-1972" /></p>
<p>Definitely a very interesting and useful feature which provides many possibilities to play around with.<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/1969/impressions-of-custom-post-type/feed/</wfw:commentRss>
		<slash:comments>112</slash:comments>
		</item>
		<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>

