<?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>Robert Iseley</title>
	<atom:link href="http://robertiseley.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://robertiseley.com</link>
	<description>Freelance PHP/Wordpress Developer</description>
	<lastBuildDate>Mon, 30 Apr 2012 17:22:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Creating Custom Post Types</title>
		<link>http://robertiseley.com/creating-custom-post-types/</link>
		<comments>http://robertiseley.com/creating-custom-post-types/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 13:52:42 +0000</pubDate>
		<dc:creator>Robert Iseley</dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://robertiseley.com/?p=179</guid>
		<description><![CDATA[In this tutorial I will go over how to create &#8220;Custom Post Types&#8221;. I will go over two methods of doing this. The first will be the WordPress &#8220;traditional&#8221; method. The other will be using a php class method(class file required). The end result will be a &#8220;books&#8221; post type with two custom taxonomies(writers and... <a href="http://robertiseley.com/creating-custom-post-types/"> [Continue Reading]</a>]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I will go over how to create &#8220;Custom Post Types&#8221;. I will go over two methods of doing this. The first will be the WordPress &#8220;traditional&#8221; method. The other will be using a php class method(class file required). The end result will be a &#8220;books&#8221; post type with two custom taxonomies(writers and genres). The traditional code for the custom post type is <a title="WP Codex Register Post Type Expamples" href="http://codex.wordpress.org/Function_Reference/register_post_type#Example" target="_blank">here</a>. The traditional code for the custom taxonomies is <a title="WP Codex Register Taxonomy Example" href="http://codex.wordpress.org/Function_Reference/register_taxonomy#Example" target="_blank">here</a>. All code will go into the functions file or a separate file that you do an include in the functions file.</p>
<h2>The Bare Minimum</h2>
<div class="post-code">
<h3>Traditional</h3>
<ol>
<li style="content: counter(item);">add_action( &#8216;init&#8217;, &#8216;codex_custom_init&#8217; );</li>
<li>function codex_custom_init() {</li>
<li>     $args = array( &#8216;public&#8217; =&gt; true, &#8216;label&#8217; =&gt; &#8216;Books&#8217; );</li>
<li>     register_post_type( &#8216;book&#8217;, $args );</li>
<li>}</li>
</ol>
</div>
<p>With the traditional method, you have to hook(add_action) in a function with your code at &#8216;init&#8217;(line 1). Line 2 you are setting arguments in an array to be used with register_post_type(line 3). Setting public to true(defaults to false), will allow you to see the post type in the backend. This also sets several other variables if left out(ie: publicly_queryable). Label will become your post type and be displayed in place of &#8216;post&#8217; normal locations.</p>
<div class="post-code">
<h3>Class Method</h3>
<ol>
<li>include(&#8216;riCustomPostTypeClass.php&#8217;);</li>
<li>$books = new riCustomPostType(&#8216;books&#8217;);</li>
<li>$books-&gt;register();</li>
</ol>
</div>
<p>With my custom class method, you will need to include the class file in order to use the class(line 1). Line 2, a class object is being created. &#8220;New&#8221; is required before the class in order to create an instance of the class. The instance is saved to a variable. Then the register class function(line 3) is ran in order to hook in the register_post_type into init. This will always be the last line for the instance.</p>
]]></content:encoded>
			<wfw:commentRss>http://robertiseley.com/creating-custom-post-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

