<?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>Mike Van WinkleTheming Custom Post Types in WordPress 3.0 | Mike Van Winkle</title>
	<atom:link href="http://www.mikevanwinkle.com/tag/custom-post-types/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mikevanwinkle.com</link>
	<description>Wordpress/PHP Developer</description>
	<lastBuildDate>Mon, 06 Feb 2012 18:55:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Theming Custom Post Types in WordPress 3.0</title>
		<link>http://www.mikevanwinkle.com/wordpress/theming-custom-post-types-in-wordpress-3-0/</link>
		<comments>http://www.mikevanwinkle.com/wordpress/theming-custom-post-types-in-wordpress-3-0/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 20:44:42 +0000</pubDate>
		<dc:creator>Mike Van Winkle</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[content management]]></category>
		<category><![CDATA[custom post types]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[wordpress tutorial]]></category>

		<guid isPermaLink="false">http://www.mikevanwinkle.com/?p=486</guid>
		<description><![CDATA[So today I developed a simple strategy for dealing with some of the theming issues that arise out of WordPress 3.0 and the new Custom Post Type functionality. The Issue: You&#8217;re working on a site designed long before Custom Post Types were an itch in Matt&#8217;s cerebellum. But now that the functionality is there and you [...]]]></description>
			<content:encoded><![CDATA[<p>So today I developed a simple strategy for dealing with some of the theming issues that arise out of <a title="Wordpress 3.0" href="http://wordpress.org/development/2010/04/wordpress-3-0-beta-1/">WordPress 3.0</a> and the new <a title="Custom Post Types" href="http://codex.wordpress.org/Function_Reference/register_post_type">Custom Post Type</a> functionality.</p>
<p><strong>The Issue: </strong>You&#8217;re working on a site designed long before <a title="Custom Post Types" href="http://codex.wordpress.org/Function_Reference/register_post_type">Custom Post Types</a> were an itch in Matt&#8217;s cerebellum. But now that the functionality is there and you want to incorporate it into your theme. Previously you used conditional code to theme your single.php file.</p>
<pre>&lt;?php if(in_category('foo')) { ?&gt;
   Do something.
&lt;?php } elseif(in_category('bar')) { ?&gt;
   Do something else.
&lt;?php } else { ?&gt;
   Do yet another thing.
&lt;?php } ?&gt;</pre>
<p>The thought of adding yet another layer of conditionals makes you sick to your stomach. <a title="Custom Post Types" href="http://codex.wordpress.org/Function_Reference/register_post_type">Custom Post Types</a> need to be treated completely different. They have different categories, taxonomies, and even different sidbars. Arg!</p>
<p><strong>Solution: </strong>One simple function. Call it whatever you want, but here&#8217;s what it looks like. When I say simple &#8230; I mean simple.</p>
<pre>
<div id="_mcePaste">function get_post_in_context() {</div>
<div id="_mcePaste">   global $post;</div>
<div id="_mcePaste">   $type = $post-&gt;post_type;</div>
<div id="_mcePaste">   include(TEMPLATEPATH .'/layouts/single-'.$type .'-content.php');</div>
<div id="_mcePaste">}</div>
</pre>
<p>Now just create a directory in your theme called &#8220;layouts&#8221;. Then copy and paste all the markup in your <strong>single.php</strong> file between the <em>get_header()</em> tag and the <em>get_sidebar()</em> tag to a file named <strong>single-post-content.php</strong> and save the file to your layouts folder.</p>
<p>Now place a the <em>get_post_in_context()</em> tag into your single.php  where you want the markup from single-post-content.php to show up.</p>
<pre><span style="font-family: Georgia, 'Bitstream Charter', serif; color: #444444;"><span style="line-height: 22px;">&lt;?php get_header(); ?&gt;
&lt;?php get_post_in_context(); ?&gt;
 &lt;?php get_sidebar(); ?&gt;
&lt;?php get_footer(); ?&gt;</span></span></pre>
<p>The beauty of this is that you can now create a new single-POSTTYPE-content.php (example:single-events-content.php) file for any of your custom post types and it will automagically get called instead of the single-post-content.php without any more changes to the single.php file.</p>
<p>I can&#8217;t take total credit for the idea. Some theme frameworks already employ a version of this strategy. But I need to adapt an existing theme rather than start from a framework. This function above will allow you to scale your existing theme to accomodate new post types without having to redesign your whole site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikevanwinkle.com/wordpress/theming-custom-post-types-in-wordpress-3-0/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Object Caching 350/365 objects using apc

Served from: www.mikevanwinkle.com @ 2012-02-09 20:52:26 -->
