<?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>Justin Tadlock &#187; Justin Tadlock</title>
	<atom:link href="http://justintadlock.com/archives/author/admin/feed" rel="self" type="application/rss+xml" />
	<link>http://justintadlock.com</link>
	<description>Life, Blogging, and WordPress</description>
	<lastBuildDate>Wed, 01 Sep 2010 14:03:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Realizing a dream: Writing a WordPress book</title>
		<link>http://justintadlock.com/archives/2010/09/01/realizing-a-dream-writing-a-wordpress-book</link>
		<comments>http://justintadlock.com/archives/2010/09/01/realizing-a-dream-writing-a-wordpress-book#comments</comments>
		<pubDate>Wed, 01 Sep 2010 14:03:59 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Writing]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2538</guid>
		<description><![CDATA[My journey to become a published author and how the WordPress community has made this possible.]]></description>
			<content:encoded><![CDATA[<p class="alert">This is a story (the short version) of my personal journey to becoming an author.  Thank you to everyone in the WordPress community that has helped make this happen by allowing me to be a part of the community over the last few years.</p>
<h2>The early years</h2>
<p>As I was growing up in smalltown Alabama, I always wanted to be a writer.  From about the time I could hold a crayon, I was writing something.  Writing on the walls.  The kitchen table.  Occasionally, on paper.  From what my parents tell me, I could do this quite well at about the age of 3.</p>
<p>During my pre-teen years, I wanted to follow in my father&#8217;s footsteps and write songs, so music and lyrics were my first introduction to how beautiful language could be.</p>
<p>Eventually, I outgrew my songwriting phase.  Be glad I did.  The world certainly doesn&#8217;t need any more boy-band pop songs.  I figured I could offer something of a little more substance to the world.</p>
<h2>High school</h2>
<p>In high school, I had the most wonderful English teacher.  She was one of those teachers that understood that literacy is not just about basic reading and writing skills.  Literature.  Technology.  Music.  Film.  Those are the things that matter.  Don&#8217;t get me wrong.  We still had to do the boring high school English class stuff.  But, she opened my mind to the world outside of the small town I was living in.</p>
<p>At some point during my senior year I realized that I wanted to write.  I mean <em>really</em> write.  It was the first time I&#8217;d ever put &#8220;write a book&#8221; on my list of life goals.</p>
<h2>College</h2>
<p>I graduated from Auburn University in 2007 with a B.A. in English and a concentration in creative writing and journalism.</p>
<p>When I began college, I didn&#8217;t plan on having a degree in English.  I was in software engineering.  Then I was in hotel and restaurant management.  Then I was in software engineering again.  Like many other college students, I bounced around majors a few times.  It was tough finding something that was both enjoyable and challenging.</p>
<p>Despite protests from friends and a few from my family, I decided to take the plunge and declare myself as an English major.  What I found was something that I loved.  How could anyone <em>not</em> love reading 20+ books a semester?  I had the time of my life exploring ethnographic studies, novels, and even the Bible as literature.</p>
<p>Each professor impacted my life in some way.  Each class allowed me to explore other cultures.  Each friend I got to know, helped shape me.</p>
<p>By the time I graduated, I had narrowed my list of life goals down to a few things.  At the top of that list:  <em>Write something that has an impact on someone&#8217;s life</em>.</p>
<p>At some point during college, I also started learning <acronym title="Hypertext Markup Language">HTML</acronym>, <acronym title="Cascading Style Sheets">CSS</acronym>, <acronym title="Hypertext Preprocessor">PHP</acronym>, and WordPress.</p>
<h2>After college</h2>
<p>Harsh realization that life is not all roses and peaches.</p>
<p>&#8230;Time spent wandering the globe&#8230;</p>
<p>I moved back to Alabama last year because I wanted to get back to my roots.  I wanted to engulf myself in the white-trash, trailer-park, tobacco-chewing culture that I hadn&#8217;t been a part of in so long.</p>
<p>The plan:  Observe the culture.  Write.</p>
<p>I could give you at least 100 reasons why I haven&#8217;t finished a novel yet, but I won&#8217;t.  There&#8217;s no point in trying to justify losing sight of my goal.</p>
<p>I also spent some more time playing around with WordPress during this phase of my life.  I suppose that time could&#8217;ve been spent working on the great Southern American novel.</p>
<h2>An opportunity</h2>
<p>A few months ago, I received an email about collaborating on a WordPress plugin development book for <a href="http://www.wrox.com" title="Wrox">Wrox</a>, a company devoted to publishing books &#8220;by programmers for programmers.&#8221;</p>
<p>At first, I was a bit hesitant to take on any extra WordPress projects.  It also meant that I wouldn&#8217;t be able to apply for teaching jobs this school year, which was one of my <a href="http://justintadlock.com/archives/2010/02/01/2010" title="2010">goals for 2010</a>.  And, it wasn&#8217;t quite what I had in mind when I put &#8220;write a book&#8221; on my list of life goals.</p>
<p>However, it was an opportunity to write about something I&#8217;m passionate about.</p>
<h2>The book</h2>
<p>We have a great team of WordPress minds melding for what will be an awesome WordPress plugin development book.  <a href="http://strangework.com/" title="Brad Williams">Brad Williams</a>, <a href="http://planetozh.com/blog/" title="planetOzh">Ozh Richard</a>, and I are the writers.  We&#8217;ve also picked up <a href="http://www.andrewnacin.com/" title="Andrew Nacin">Andrew Nacin</a> as our WordPress technical editor.</p>
<p class="note">As a sidenote to this:  I&#8217;m convinced that Andrew is actually a super-advanced robot that has been programmed to do nothing other than write awesome WordPress code.  And, I&#8217;m happy to have him on the team.</p>
<p>I don&#8217;t want to get into too many technical details about the book yet.  I do want to say that it will be a great resource for professional plugin development.  We will put everything we have into making this the best book on creating plugins available for WordPress.</p>
<p>For me, this book announcement is mostly about sharing my personal journey to this point.  I am thankful that Wrox, Brad, and Ozh are giving me an opportunity to realize one of my lifelong dreams.  And, I hope that all my readers will come along on this journey with me (and buy the book when it&#8217;s published in March).</p>
<p>Also, check out theses posts by Brad and Ozh:</p>
<ul>
<li><a href="http://www.strangework.com/2010/09/01/new-book-professional-wordpress-plugin-development/" title="New Book: Professional WordPress Plugin Development!">New Book: Professional WordPress Plugin Development</a></li>
<li><a href="http://planetozh.com/blog/2010/09/into-plugins-you-will-love-this-plugindevbook/" title="Into Plugins?  You Will Love This.">Into Plugins?  You Will Love This.</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2010/09/01/realizing-a-dream-writing-a-wordpress-book/feed</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>Post types and taxonomies: Linking terms to a specific post</title>
		<link>http://justintadlock.com/archives/2010/08/20/linking-terms-to-a-specific-post</link>
		<comments>http://justintadlock.com/archives/2010/08/20/linking-terms-to-a-specific-post#comments</comments>
		<pubDate>Fri, 20 Aug 2010 14:05:53 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2525</guid>
		<description><![CDATA[When is something both a taxonomy term and post of a specific post type?  How do we handle that scenario in WordPress?]]></description>
			<content:encoded><![CDATA[<p>Almost every week I get asked a question about custom WordPress taxonomies and post types that has been bothering me for quite a while.  I&#8217;ve thought over several solutions to the question and haven&#8217;t necessarily found the perfect one, but I have found one that may work in some cases.</p>
<p>The question usually goes back to my original post on creating a <a href="http://justintadlock.com/archives/2009/06/04/using-custom-taxonomies-to-create-a-movie-database" title="Using custom taxonomies to create a movie database">movie database with taxonomies</a>.  In the tutorial, I explain how to make several taxonomies that represent people (actor, director, producer, and writer).  Taxonomies give us a way to clearly label and organize what roles a person takes on within the production of a movie.  The relationship between the given taxonomy and the movie post type usually stops there.</p>
<p>The question: <em>How does one make an &#8220;actor&#8221; both a taxonomy term and a post of a specific post type?</em></p>
<p>That&#8217;s essentially what most of the questions boil down to.  We want the clear organizational structure of taxonomies, but we also want each term in a taxonomy to behave as if it were a post/page with the ability to edit the content, upload media, have custom fields, and allow comments.  So, we also need a &#8220;person&#8221; post type to handle this.</p>
<p>Creating taxonomies and post types is the easy part.  Making the connection we want is the complex part of the question.</p>
<p><img src="http://justintadlock.com/blog/wp-content/uploads/2010/08/taxonomy-to-post-type.png" alt="Taxonomy to post type" title="Making an object both a taxonomy and post type" /></p>
<h2>What we&#8217;re doing</h2>
<p>In this tutorial, we&#8217;re trying to make connections between two post types and one taxonomy.</p>
<ul>
<li>Movie (post type).</li>
<li>Person (post type).</li>
<li>Actor (taxonomy).</li>
</ul>
<p>In my movie database example, we&#8217;d be making the connection with several taxonomies.  But, I want to keep this tutorial simple.</p>
<p>The goal is to create a &#8220;movie&#8221; and list its actors on the movie page.  But, instead of going to an actor archive when clicking on one of the actor&#8217;s names, we want to visit a &#8220;person&#8221; page with custom content.  This would allow you to write custom content, upload images, add videos, open up the commenting section, and do all the things you&#8217;d normally be able to do with posts.</p>
<p>On the movie database, when we see Tom Hanks listed as an actor, we&#8217;d want to visit a <a href="http://popcritics.com/people/tom-hanks" title="Tom Hanks at Pop Critics">custom person page</a> we set up for him.</p>
<h2>Post type and taxonomy setup</h2>
<p class="alert">The rest of this tutorial assumes a working knowledge of creating post types and taxonomies.  The examples below will be limited and likely won&#8217;t be helpful unless you have an understanding of this process.  Please read my previous tutorials on <a href="http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress" title="Custom post types in WordPress">post types</a> and <a href="http://justintadlock.com/archives/2010/06/10/a-refresher-on-custom-taxonomies" title="A refresher on custom taxonomies">taxonomies</a> for a more in-depth review.</p>
<p>Open your theme&#8217;s <code>functions.php</code> file and add this <acronym title="Hypertext Preprocessor">PHP</acronym> code to create the movie and person post types.</p>
<pre><code>add_action( 'init', 'my_register_post_types' );

function my_register_post_types() {

	register_post_type(
		'movie',
		array(
			'public' => true,
			'labels' => array( 'name' => 'Movies', 'singular_name' => 'Movie' )
		)
	);

	register_post_type(
		'person',
		array(
			'public' => true,
			'labels' => array( 'name' => 'People', 'singular_name' => 'Person' )
		)
	);
}</code></pre>
<p>Now, let&#8217;s add some code for our actor taxonomy.</p>
<pre><code>add_action( 'init', 'my_register_taxonomies' );

function my_register_taxonomies() {

	register_taxonomy(
		'actor',
		array( 'movie' ),
		array(
			'public' => true,
			'labels' => array( 'name' => 'Actors', 'singular_name' => 'Actor' )
		)
	);
}</code></pre>
<p>That should give us a simple setup to work with and base to build our new functionality on.</p>
<p>The biggest thing to note here is that we have to be careful with our actor and person slugs.  When we create a new actor (term), we need to have the exact same slug as the person (post).  For example, when creating the Tom Hanks &#8220;actor,&#8221; it needs to have the slug of <code>tom-hanks</code>.  And, when we create the Tom Hanks &#8220;person,&#8221; it needs to have the slug of <code>tom-hanks</code>.  Otherwise, the proposed solutions below won&#8217;t work.</p>
<h2>Option #1: Changing term links to post permalinks</h2>
<p>One option is to change the links to actor archives to a specific post.  We&#8217;ll be working with term and post slugs in this step.  I normally don&#8217;t recommend using slugs because IDs are usually best to work with.  They don&#8217;t change and slugs can.  Unfortunately, connecting the terms and posts via ID isn&#8217;t something we can do right now.</p>
<p>The code below will do this step automatically for you.  What it does is filter <code>term_link</code> (link to actor archive page).  It grabs the term slug (actor name) and searches for a post slug that matches the term slug and has a post type of &#8220;person.&#8221;  If it finds the post, it switches the link for you.  Otherwise, it does nothing.</p>
<p>If you&#8217;re listing a ton of terms on one page, this solution isn&#8217;t ideal unless you mix it in with a caching solution.</p>
<pre><code>add_filter( 'term_link', 'my_term_to_type', 10, 3 );

function my_term_to_type( $link, $term, $taxonomy ) {

	if ( 'actor' == $taxonomy ) {
		$post_id = my_get_post_id_by_slug( $term->slug, 'person' );

		if ( !empty( $post_id ) )
			return get_permalink( $post_id );
	}

	return $link;
}

function my_get_post_id_by_slug( $slug, $post_type ) {
	global $wpdb;

	$slug = rawurlencode( urldecode( $slug ) );
	$slug = sanitize_title( basename( $slug ) );

	$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = %s", $slug, $post_type ) );

	if ( is_array( $post_id ) )
		return $post_id[0];
	elseif ( !empty( $post_id ) );
		return $post_id;

	return false;
}</code></pre>
<h2>Option #2: Redirect term archives to posts</h2>
<p>In the above example, term archives are still publicly available.  We&#8217;re not doing a redirect, so it&#8217;s possible for someone to still stumble upon the archive or for you to even make it available if you wanted to.  But, if you&#8217;re looking for a way to redirect anyone that visits a term archive to the appropriate post, use the code below.  This method is also a lot more efficient.</p>
<p>Use this code in your <code>functions.php</code> file.</p>
<pre><code>add_action( 'template_redirect', 'my_redirect_term_to_post' );

function my_redirect_term_to_post() {
	global $wp_query;

	if ( is_tax() ) {
		$term = $wp_query->get_queried_object();

		if ( 'actor' == $term->taxonomy ) {
			$post_id = my_get_post_id_by_slug( $term->slug, 'person' );

			if ( !empty( $post_id ) )
				wp_redirect( get_permalink( $post_id ), 301 );
		}
	}
}

function my_get_post_id_by_slug( $slug, $post_type ) {
	global $wpdb;

	$slug = rawurlencode( urldecode( $slug ) );
	$slug = sanitize_title( basename( $slug ) );

	$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = %s", $slug, $post_type ) );

	if ( is_array( $post_id ) )
		return $post_id[0];
	elseif ( !empty( $post_id ) );
		return $post_id;

	return false;
}</code></pre>
<h2>Asking for a term meta table</h2>
<p>There has been some discussion in the WordPress community about adding a <a href="http://core.trac.wordpress.org/ticket/10142" title="Add metadata support for taxonomies">term meta table</a> to the WordPress core.  I can list a ton of reasons this would be a great idea, but let me just focus on how it would make the above solutions even better.</p>
<p>Right now (in the examples), we&#8217;re calling up the database to search for a post based on a slug.  This isn&#8217;t something I really like to do on the front end, especially with the first example.  For example, listing 50 actors on a page using the first option would cause us to search the database 50 times to see if a post slug matches the taxonomy term.</p>
<p>A term meta table would easily solve this problem.  We could save the post ID as metadata for individual terms.  We could even do the post lookup in the backend instead of doing it on-the-fly on the front end of the site.  Or, even provide a nice interface for easily selecting the post/term we want to connect.  Having term meta would allow us to do a quick check if there&#8217;s a post we want to redirect to.</p>
<h2>Other solutions and thoughts</h2>
<p>The above solutions are just something I was tinkering around with because of the enormous number of questions I get about this.  I haven&#8217;t fully explored every possible option, so I can&#8217;t say that either is the best route to take.  Think of it more as &#8220;Justin thinking out loud&#8221; than a definite solution.</p>
<p>I would love to hear your take on other solutions or even solutions that we could try to get rolled into core to better handle metadata and relationships between post types and taxonomies.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2010/08/20/linking-terms-to-a-specific-post/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Frameworks? Parent, child, and grandchild themes?</title>
		<link>http://justintadlock.com/archives/2010/08/16/frameworks-parent-child-and-grandchild-themes</link>
		<comments>http://justintadlock.com/archives/2010/08/16/frameworks-parent-child-and-grandchild-themes#comments</comments>
		<pubDate>Mon, 16 Aug 2010 17:05:49 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Discussion]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2517</guid>
		<description><![CDATA[Solving the big mystery of parent, child, and grandchild themes by explaining what theme frameworks really are.]]></description>
			<content:encoded><![CDATA[<p>One question that crops up every once in a while from my theme users is how to create a WordPress grandchild theme.  Most of the time, a user asks, &#8220;How do I update my child theme?  Do I need to create a grandchild theme?&#8221;</p>
<p>The idea of parent/child themes was created so that the parent theme could be updated while keeping customizations intact within a child theme.  That system works great.  The problems begin when a child theme is updated.  Users tend to want to take advantage of the update, but they can&#8217;t upgrade because they&#8217;ve made customizations. </p>
<p>Essentially, we&#8217;ve just added another layer to the preexisting problem.</p>
<p>But, that&#8217;s not where the <em>real</em> problem is at.  The problem is confusion over what frameworks, parent themes, and child themes are.  Users aren&#8217;t to blame for this confusion.  Theme developers are at fault here (even me), and I&#8217;m going to attempt to clear things up.</p>
<h2>Advanced parent themes are not frameworks</h2>
<p>I&#8217;m going to avoid calling any other &#8220;framework&#8221; themes out and tell you that my own <a href="http://themehybrid.com/themes/hybrid" title="Hybrid WordPress theme">Hybrid theme</a> is not a framework, at least not in the traditional development framework sense.  It&#8217;s an advanced parent theme.  Admittedly, I&#8217;ve called it a &#8220;framework&#8221; before because I&#8217;ve just been following the crowd.</p>
<p>What should we call the <em>Hybrid</em> theme?  Simple.  It&#8217;s a parent theme.</p>
<p>One thing we should definitely not confuse are the terms &#8220;framework&#8221; and &#8220;parent theme.&#8221;  These two are not interchangeable.  That&#8217;s where a lot of the confusion stems from.</p>
<h2>What is a theme framework?</h2>
<p class="note">This is the question I most wanted to answer because I&#8217;ll be releasing a framework for theme developers soon (see below).  But, I can&#8217;t do that with all this confusion floating around the community.</p>
<p>A theme framework is a set of conventions to use for developing WordPress [parent] themes.</p>
<p>Yes, that&#8217;s a bit vague, but frameworks can exist for all kinds of different purposes.  This can be something like an elegant template engine (<a href="http://carringtontheme.com/" title="Carrington Theme Framework">Carrington Core</a> is really good for this) or a set of helper functions for more quickly building a theme.</p>
<p>It is not a theme though.  You can&#8217;t simply drop it in your WordPress themes directory and expect it to work.</p>
<p>Frameworks are for theme developers.  They offer a set of standards (or whatever features) for theme developers to use in creating their own themes.  They&#8217;re a set of functions/features created to aid development.</p>
<h2>What is a parent theme?</h2>
<p>Nearly all WordPress themes are parent themes.  Only those called &#8220;child themes&#8221; are not parent themes.</p>
<p>Theme developers create parent themes for users to download and install on their sites.  My <em>Hybrid</em> theme is, without a doubt, a parent theme.  Parent themes should house the theme design, functionality, and the templates required for running the theme in WordPress.</p>
<p>You can use a framework to build a parent theme, but the framework is not a parent theme itself.</p>
<h2>What is a child theme?</h2>
<p>A child theme is something users should be creating so that they can customize the look and functionality of their site.  The child theme inherits all of its functionality from a single parent theme.</p>
<p>When a theme developer creates a child theme, things become problematic because that child theme might eventually need an update.  If you&#8217;re a theme developer and are building a child theme with a 20kb functions file and five or six custom templates, I can assure you that you&#8217;re doing it wrong.  I&#8217;ve even had to tell myself this.</p>
<p>What you should really be creating is a parent theme.  Child themes from theme developers should be nothing more than a stylesheet and a few functions.  This idea of releasing advanced child themes just creates the same problem child themes were meant to solve: <em>upgradability</em>.</p>
<p>I&#8217;ve got over two years of experience at this point in dealing with parent/child themes if you need a reason to take my advice on this.</p>
<h2>How frameworks work</h2>
<p><em>Confused yet?</em>  Let me break this process down for you and explain how it <em>should</em> work.</p>
<ul>
<li>Frameworks come packaged within a single folder.</li>
<li>Developers drop the framework folder into a new parent theme and load the framework.</li>
<li>Users create a child theme based on the parent theme to house their customizations, allowing both the framework and parent theme to be updated.</li>
</ul>
<p>Here&#8217;s a diagram for reference:</p>
<p><img src="http://justintadlock.com/blog/wp-content/uploads/2010/08/framework-parent-child.png" alt="Theme structure when using a framework, parent theme, and child theme" title="Framework theme structure" width="600" height="485" class="aligncenter size-full wp-image-2521" /></p>
<p>Users should only ever have to worry about creating a child theme.  This will allow them to make modifications without losing them when the parent theme is updated.  They shouldn&#8217;t have to worry about all the other stuff.</p>
<p>As you can see by now (I hope), the question of grandchild themes has been completely averted because theme developers shouldn&#8217;t be adding advanced functionality (that might need future updating) within child themes.</p>
<h2>Doesn&#8217;t Hybrid break these rules?</h2>
<p>The <em>Hybrid</em> parent theme doesn&#8217;t break the rules.  A couple of the child themes?  Definitely.  If I could afford a time-traveling machine (and if they existed), I&#8217;d zip back a year or two and turn a couple of those child themes into parent themes instead.  We all have to learn from our mistakes, and I can freely admit that I&#8217;ve taken the wrong route on occasion.</p>
<p>So, I&#8217;m going to give you a real-world example of everything I&#8217;ve been talking about and how it could&#8217;ve been avoided with one of my own themes.</p>
<p><em>Hybrid</em> has a child theme called <a href="http://themehybrid.com/themes/hybrid-news" title="Hybrid News WordPress theme">Hybrid News</a>.  This child theme has a few extra features that make it more advanced than its parent theme.  One good example of a problem was when WordPress 3.0 launched with a new <a href="http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus" title="Goodbye, headaches. Hello, menus!">menu system</a> (which I love).  The <em>Hybrid News</em> child theme has an extra navigation menu that&#8217;s not present within its parent theme.</p>
<p>The problem:  How do you upgrade the <em>Hybrid News</em> child theme to use the the new nav menu system for its extra menu?</p>
<p>You certainly can&#8217;t expect users to upgrade the child theme and lose all of their customizations.  To solve this particular problem, I wrote a tutorial on making the switch to the new system.  But, it was just a way to avoid the larger problem at hand.</p>
<p>The solution should&#8217;ve been:  Make <em>Hybrid News</em> a parent theme.  This would allow it to be upgraded and users to keep their customizations intact.</p>
<p>If you&#8217;re a theme developer with a lot of advanced child themes, you may be thinking that you&#8217;ve got this problem all figured out.  You may have already come up with plenty of nifty solutions for avoiding these types of problems.  But, no one can foresee what new things will come in later versions of WordPress to conflict with those solutions.</p>
<h2>Introducing Hybrid Core: A theme framework</h2>
<p>Last year, I mentioned that I&#8217;d <a href="http://themehybrid.com/archives/2009/11/whats-in-store-for-hybrid-0-7" title="What's in store for Hybrid 0.7">release Hybrid Core</a> to the public for download.  Unfortunately, that release never came out.  I wanted some more time to perfect it, which turned out to be around a year worth of extra time.</p>
<p><em>Hybrid Core</em> will be a theme development framework for use by other theme developers.  What this means is that any theme developer will be able to download this and build parent themes with an awesome framework behind them.  Yes, I&#8217;m essentially giving you the keys to the <a href="http://themehybrid.com" title="Theme Hybrid">Theme Hybrid</a> kingdom.</p>
<p><em>Hybrid Core</em> is currently packaged within my <em>Hybrid</em> parent theme.  It is used to handle the &#8220;logic&#8221; behind how the theme runs.  Theme developers will be able to load this framework and build themes using the set of conventions provided by the framework.  All of the <acronym title="Hypertext Markup Language">HTML</acronym>, <acronym title="Cascading Style Sheets">CSS</acronym>, and extra functionality will be left up to you. </p>
<p>In the next month or two, I&#8217;ll be putting the finishing touches on this.  I&#8217;m still moving some stuff around that&#8217;s specific to the <em>Hybrid</em> parent theme and getting it out of the way.</p>
<p>It&#8217;d be awesome to see many great themes built off this framework.  It&#8217;s a project that I started building in June 2008, so a lot of work and testing have been put into it.  The next theme I build will be a parent theme based off it, so you&#8217;ll have a good, working example of how to use the framework.</p>
<p class="alert">Just in case you were wondering if building a &#8220;grandchild&#8221; theme is actually possible, the answer is no, at least not by default.  And, I hope to never see the day it happens.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2010/08/16/frameworks-parent-child-and-grandchild-themes/feed</wfw:commentRss>
		<slash:comments>68</slash:comments>
		</item>
		<item>
		<title>Fashion</title>
		<link>http://justintadlock.com/quotes/entry/fashion</link>
		<comments>http://justintadlock.com/quotes/entry/fashion#comments</comments>
		<pubDate>Sun, 08 Aug 2010 08:14:41 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
		
		<guid isPermaLink="false">http://justintadlock.com/?post_type=quote&#038;p=2513</guid>
		<description><![CDATA[Fashion is a form of ugliness so intolerable that we have to alter it every six months. &#8212; Oscar Wilde]]></description>
			<content:encoded><![CDATA[<p>Fashion is a form of ugliness so intolerable that we have to alter it every six months.<span class="person"> &mdash; <cite><a href="http://justintadlock.com/people/oscar-wilde" rel="tag">Oscar Wilde</a></cite></span></p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/quotes/entry/fashion/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Linking post published dates to their archives</title>
		<link>http://justintadlock.com/archives/2010/08/06/linking-post-published-dates-to-their-archives</link>
		<comments>http://justintadlock.com/archives/2010/08/06/linking-post-published-dates-to-their-archives#comments</comments>
		<pubDate>Sat, 07 Aug 2010 04:39:22 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2507</guid>
		<description><![CDATA[Giving the post published date/time on WordPress a purpose by linking its individual parts to date-based archives.]]></description>
			<content:encoded><![CDATA[<p>I was just thinking the other day that date-based archives in most WordPress blogs don&#8217;t get enough exposure unless the blog owner uses a widget to show a list of archives.  Since I&#8217;m not a big fan of using long lists of archives in the sidebar and wasting valuable space, this method was out of the question for me.  </p>
<p>But, I still wanted a way to easily allow readers to visit my archives.  I also wanted to not just show monthly archives like the standard WordPress archives widget.  The method I decided on has three major benefits:</p>
<ul>
<li>Allows readers to find archives by year, month, and day.</li>
<li>Doesn&#8217;t take up any extra space on my blog.</li>
<li>The code was already written in my <a href="http://justintadlock.com/archives/2009/04/05/breadcrumb-trail-wordpress-plugin" title="Breadcrumb Trail WordPress plugin">Breadrumb Trail plugin</a>, so there wasn&#8217;t much I had to do.</li>
</ul>
<p>On this blog and many others, we have a thing called a <em>byline</em> or <em>dateline</em>, which is usually located before or after the post title.  Traditionally, the date the post was written is shown.  But, it doesn&#8217;t do much.  It just sits there.  Yes, it provides valuable information to the user but not anything more than that.</p>
<p>What we&#8217;re going to do is link the various parts of the date to archive pages.  We&#8217;re going to give the post date more purpose.</p>
<h2>Creating the post date link function</h2>
<p>The first thing we need to do is create a function in our theme&#8217;s <code>functions.php</code> file.  Actually, we&#8217;re going to create a function and a shortcode.  Just drop this <acronym title="Hypertext Preprocessor">PHP</acronym> code in the file:</p>
<pre><code>&lt;?php

add_shortcode( 'entry-link-published', 'my_entry_published_link' );

function my_entry_published_link() {

	/* Get the year, month, and day of the current post. */
	$year = get_the_time( 'Y' );
	$month = get_the_time( 'm' );
	$day = get_the_time( 'd' );
	$out = '';

	/* Add a link to the monthly archive. */
	$out .= '&lt;a href="' . get_month_link( $year, $month ) . '" title="Archive for ' . esc_attr( get_the_time( 'F Y' ) ) . '">' . get_the_time( 'F' ) . '&lt;/a>';

	/* Add a link to the daily archive. */
	$out .= ' &lt;a href="' . get_day_link( $year, $month, $day ) . '" title="Archive for ' . esc_attr( get_the_time( 'F d, Y' ) ) . '">' . $day . '&lt;/a>';

	/* Add a link to the yearly archive. */
	$out .= ', &lt;a href="' . get_year_link( $year ) . '" title="Archive for ' . esc_attr( $year ) . '">' . $year . '&lt;/a>';

	return $out;
}

?></code></pre>
<p>For non-American users, you might want to switch the dates around as I&#8217;m using the &#8220;Month Day, Year&#8221; format.  The WordPress Codex also has a helpful guide on <a href="http://codex.wordpress.org/Formatting_Date_and_Time" title="WordPress Codex: Formatting date and time">formatting date and time</a> if you want to mix things up a bit.</p>
<p class="alert"><strong>Note to theme authors:</strong>  Please don&#8217;t implement this function as is into your themes.  There are tons of variations on the date/time format and we have to respect what the user chooses unless the design can&#8217;t be accomplished without a specific format.  If you come up with a way to handle all scenarios, then by all means, go for it.</p>
<h2>Using the published link in your theme</h2>
<p>We&#8217;ve added the function to run this to our theme&#8217;s <code>functions.php</code> file.  Now, we have to use the function in our theme.  All themes are going to be a little different, so I can&#8217;t tell you exactly where to put the code.  You&#8217;ll just have to look in your theme templates or ask your theme author how to do it.  I can tell you that this code should go within The Loop.</p>
<p>This is the code you add to the template:</p>
<pre><code>&lt;?php echo my_entry_published_link(); ?></code></pre>
<p>That&#8217;s all the code you have to deal with.</p>
<p>If you&#8217;re using a super-intelligent theme like <a href="http://themehybrid.com/themes/hybrid" title="Hybrid WordPress theme">Hybrid</a>, you can use the <code>&#091;entry-link-published&#093;</code> shortcode and not worry about adding the <acronym title="Hypertext Preprocessor">PHP</acronym> function.</p>
<p>Or, if you&#8217;re not using Hybrid and just want to know how to run a shortcode in a theme template, try this out:</p>
<pre><code>&lt;?php echo do_shortcode( '&#091;entry-link-published&#093;' ); ?></code></pre>
<h2>What are the benefits of doing this?</h2>
<p>I count two main benefits:</p>
<ul>
<li>Providing an easy way for readers to visit your archives.  It never hurts to implement more methods of keeping people on your site.</li>
<li>It&#8217;s just something fun to do.  Maybe spruce up your blog a little.</li>
</ul>
<p>Maybe it&#8217;ll even help search engines crawl your site easier.  I don&#8217;t know.  I quit trying to figure them out a long time ago.</p>
<p>I hope you enjoy this little snippet of code.  If you want to see it in action, I&#8217;m using it on my blog now.  Just look at my post byline and you&#8217;ll see the date linked to three different archives.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2010/08/06/linking-post-published-dates-to-their-archives/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Burn books to destroy a culture</title>
		<link>http://justintadlock.com/quotes/entry/burn-books-to-destroy-a-culture</link>
		<comments>http://justintadlock.com/quotes/entry/burn-books-to-destroy-a-culture#comments</comments>
		<pubDate>Fri, 30 Jul 2010 03:42:45 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
		
		<guid isPermaLink="false">http://justintadlock.com/?post_type=quote&#038;p=2504</guid>
		<description><![CDATA[You don&#8217;t have to burn books to destroy a culture. Just get people to stop reading them. &#8212; Ray Bradbury]]></description>
			<content:encoded><![CDATA[<p>You don&#8217;t have to burn books to destroy a culture. Just get people to stop reading them.<span class="person"> &mdash; <cite><a href="http://justintadlock.com/people/ray-bradbury" rel="tag">Ray Bradbury</a></cite></span></p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/quotes/entry/burn-books-to-destroy-a-culture/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>TV Shows On DVD</title>
		<link>http://justintadlock.com/asides/note/tv-shows-on-dvd</link>
		<comments>http://justintadlock.com/asides/note/tv-shows-on-dvd#comments</comments>
		<pubDate>Wed, 28 Jul 2010 02:22:54 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
		
		<guid isPermaLink="false">http://justintadlock.com/?post_type=aside&#038;p=2500</guid>
		<description><![CDATA[TV Shows On DVD is one of my favorite websites. The site&#8217;s design looks like it hasn&#8217;t been updated since the &#8217;90s, but this only helps prove that content is more important than spiffy graphics (though I&#8217;d update it in a heartbeat given the chance). It has relevant, up-to-date information, and that is enough to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tvshowsondvd.com" title="TV Shows On DVD">TV Shows On DVD</a> is one of my favorite websites.  The site&#8217;s design looks like it hasn&#8217;t been updated since the &#8217;90s, but this only helps prove that content is more important than spiffy graphics (though I&#8217;d update it in a heartbeat given the chance).  It has relevant, up-to-date information, and that is enough to satisfy me.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/asides/note/tv-shows-on-dvd/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>A WordPress forum plugin using custom post types</title>
		<link>http://justintadlock.com/archives/2010/07/16/a-wordpress-forum-plugin-using-custom-post-types</link>
		<comments>http://justintadlock.com/archives/2010/07/16/a-wordpress-forum-plugin-using-custom-post-types#comments</comments>
		<pubDate>Fri, 16 Jul 2010 12:27:46 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2474</guid>
		<description><![CDATA[How I'm using custom post types and taxonomies to create a forum plugin that integrates full into WordPress.]]></description>
			<content:encoded><![CDATA[<p><a href="http://popcritics.com/forums" title="Pop Critics forums"><img src="http://justintadlock.com/blog/wp-content/uploads/2010/07/pop-critics-forums-300x356.png" alt="Example screenshot of a WordPress forum plugin" title="Forums plugin example" width="300" height="356" class="alignright size-medium wp-image-2476" /></a></p>
<p>I&#8217;ve been promising a real-world example of what&#8217;s possible with custom post types for a while.  But, I didn&#8217;t want to put together <em>yet-another-long-technically-detailed</em> post.  I wanted to give you something that would open your mind to the possibilities.</p>
<p>And, there&#8217;s loads of possibilities.</p>
<p>I&#8217;ve been tinkering around with the idea of building a forum plugin, so I decided to get behind the project completely and make it happen.  What started out as a simple project quickly turned into something that a lot of people have been wanting &mdash; a forum plugin that fully integrates itself within WordPress.</p>
<h2>Post types for the plugin</h2>
<p>The plugin uses three post types for handling the structure:</p>
<ul>
<li><strong>Forums:</strong> This is your top level, which holds everything else.</li>
<li><strong>Topics:</strong> Children of forums and use the topic tags taxonomy.</li>
<li><strong>Replies:</strong> These are the individual posts made within a topic.</li>
</ul>
<p>I had originally taken a different route of using a forum taxonomy, topic post type, and reply comment type.  However, using that structure had major limitations.</p>
<p>The benefits of using three post types are numerous.  Here are some examples:</p>
<ul>
<li>Forums can have metadata (custom fields) and media attachments added to them to allow a lot of cool stuff (forum thumbnails, for example).</li>
<li>You get pretty permalinks using a reply post type (<code>forums/topic-name/page/2</code>).</li>
<li>Replies can also have their own media attachments (user-uploaded images).</li>
<li>Capabilities/permissions are handled a lot better with post types.</li>
<li>Can set up custom post statuses such as &#8220;closed&#8221; and use the current statuses like &#8220;private.&#8221;</li>
<li>Works well with plugins that allow you to edit from the front end of the site.</li>
</ul>
<p>This is not to say there aren&#8217;t issues with this method.  There&#8217;s a lot of custom work work that needed to be done, which isn&#8217;t surprising considering I&#8217;m using <em>custom</em> post types.</p>
<p class="note">I can&#8217;t take all the credit for this idea of using three post types.  <a href="http://johnjamesjacoby.com" title="John James Jacoby">John James Jacoby</a> convinced me this was the best route to go.</p>
<h2>Taxonomies for the plugin</h2>
<p>The only taxonomy used by default is the topic tag taxonomy.  It allows users to assign tags to specific topics.</p>
<p>The great thing about the plugin though is that you can build custom taxonomies on top of it.  You can give forums, topics, and replies their own taxonomies if you wanted.  Since we&#8217;re using custom post types for those things, the possibilities are endless.</p>
<h2>Integration with WordPress</h2>
<p>Obviously, we want our forum plugin to work well with WordPress.  Some of the current problems users of other forum software are facing when integrating are:</p>
<ul>
<li>Separate user login pages (and separate user database tables in some cases).</li>
<li>Separate roles and permissions setups.</li>
<li>Using multiple themes to get the same design across the site.</li>
<li>Not being able to use WordPress plugins within the forum.</li>
<li>Having to figure out how &#8220;deep integration&#8221; works just to use things like menus and widgets.</li>
</ul>
<p>My plugin seeks to solve those issues and use the tools available in WordPress.</p>
<h2>Lightweight</h2>
<p>I&#8217;m not a fan of adding every fancy gizmo and gadget in the world to a forum.  I like to keep things simple and extend it with other plugins when I need a new feature.  I also don&#8217;t want 20 theme templates when I can use a handful.</p>
<p>The biggest goal I have is to keep this thing as lightweight as possible.  There are over 10,000 plugins for WordPress that will allow this plugin to be extended.</p>
<h2>What about the bbPress plugin?</h2>
<p>While this is outside the scope of what I&#8217;d planned on writing about, I know questions about bbPress will crop up.  I&#8217;ll try to address those.</p>
<p>It&#8217;s true that bbPress will be <a href="http://bbpress.org/forums/topic/bbpress-plugin-is-born" title="bbPress plugin is born">becoming a plugin</a> in the future and work has already started on it.  I&#8217;m happy that there&#8217;s at least something happening.  I love bbPress and have been using it for years, but I can&#8217;t wait around six or seven months again to see where the project is headed.  I&#8217;m not saying bbPress isn&#8217;t going anywhere, but I had to make the decision to move forward on my own after the last disappointment.</p>
<p>I&#8217;d love to be involved in the bbPress plugin project at some point, but my priorities right now don&#8217;t mesh well with it.  It&#8217;d also be great if the ideas used in my plugin or any of its code gets used in the bbPress plugin.</p>
<p>One thing I will promise to plugin users is that I&#8217;ll try to make it as easy as possible to switch between either plugin if that&#8217;s what they choose to do.</p>
<h2>Demo and testing</h2>
<p>The plugin isn&#8217;t ready for a public release right now.  There&#8217;s tons of work still ahead.  But, testing does need to be done on a large enough scale for me to make this a solid plugin.</p>
<p>I&#8217;ve put the plugin on one of my own sites for live testing.  If you have any interest in this plugin at all or just want to help test, please register for my <a href="http://popcritics.com/forums" title="Pop Critics forums">forums at Pop Critics</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2010/07/16/a-wordpress-forum-plugin-using-custom-post-types/feed</wfw:commentRss>
		<slash:comments>102</slash:comments>
		</item>
		<item>
		<title>Meta capabilities for custom post types</title>
		<link>http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom-post-types</link>
		<comments>http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom-post-types#comments</comments>
		<pubDate>Sat, 10 Jul 2010 07:46:19 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2462</guid>
		<description><![CDATA[How to map meta capabilities for editing, deleting, and reading custom post types in WordPress.]]></description>
			<content:encoded><![CDATA[<p>While I was fiddling around with a new plugin that uses custom post types for WordPress the other day, I ran into a small issue that I hadn&#8217;t noticed before.  Meta capabilities for custom post types were not being automatically mapped, so I couldn&#8217;t have granular control over permissions.</p>
<p>At first, I was a bit disappointed that this wasn&#8217;t taken care of because this would be a major blow to my plugin.  However, I soon learned this could be considered a great feature rather than a bug.  </p>
<p><a href="http://andrewnacin.com" title="Andrew Nacin">Andrew Nacin</a> mentioned that we&#8217;d need to &#8220;<a href="http://core.trac.wordpress.org/ticket/14122#comment:1" title="Custom 'capabilities' appears broken on custom post types">roll our own handling</a>&#8221; for capabilities using the <code>map_meta_cap</code> hook.  This hook gives you control over the meta capabilities as well as the power to step outside of the WordPress way of doing things.  The more I play around with it, the more I&#8217;d rather WordPress <em>not</em> automatically map these.</p>
<p class="alert">Before reading on, please note that this is only an issue/feature if you&#8217;re using custom capabilities for your post types.  If not, this might not interest you much.</p>
<h2>What are meta capabilities?</h2>
<p>Meta capabilities are capabilities a user is granted on a per-post basis.  The three we&#8217;re dealing with here are:</p>
<ul>
<li><code>edit_post</code></li>
<li><code>delete_post</code></li>
<li><code>read_post</code></li>
</ul>
<p>For regular blog posts, WordPress &#8220;maps&#8221; these to specific capabilities granted to user roles.  For example, a user might be given the <code>edit_post</code> capability for post 100 if they are the post author or have the <code>edit_others_posts</code> capability.</p>
<p>When using custom post types, this mapping doesn&#8217;t happen automatically if you&#8217;re setting up custom capabilities.  We have to come up with our own solution.</p>
<p>In this tutorial, I&#8217;ll be using the <code>movie</code> post type, so the above three meta capabilities for our purposes will be:</p>
<ul>
<li><code>edit_movie</code></li>
<li><code>delete_movie</code></li>
<li><code>read_movie</code></li>
</ul>
<h2>Setting up your custom post type</h2>
<p>At this point, I&#8217;ll assume you&#8217;re familiar with creating custom post types.  If not, you&#8217;ll want to read through my <a href="http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress" title="Custom post types in WordPress">detailed tutorial</a> on them.  The code presented below will be an abridged version of what you might use.</p>
<p>We&#8217;re going to focus on two arguments, <code>capability_type</code> and <code>capabilities</code>.  These control the permissions for what a user with a specific role can do with the post type.</p>
<p>As mentioned earlier, the post type we&#8217;re going with is <code>movie</code>.  So, let&#8217;s set up that post type:</p>
<pre><code>add_action( 'init', 'create_my_post_types' );

function create_my_post_types() {
	register_post_type(
		'movie',
		array(
			'public' => true,
			'capability_type' => 'movie',
			'capabilities' => array(
				'publish_posts' => 'publish_movies',
				'edit_posts' => 'edit_movies',
				'edit_others_posts' => 'edit_others_movies',
				'delete_posts' => 'delete_movies',
				'delete_others_posts' => 'delete_others_movies',
				'read_private_posts' => 'read_private_movies',
				'edit_post' => 'edit_movie',
				'delete_post' => 'delete_movie',
				'read_post' => 'read_movie',
			),
		)
	);
}</code></pre>
<p>I&#8217;ve also added in a couple of extra capabilities that were not shown in my previous tutorial on post types: <code>delete_posts</code> and <code>delete_others_posts</code>.  We&#8217;re going to use these to give people the ability to delete posts (movies).</p>
<h2>Assigning capabilities to roles</h2>
<p>To assign specific capabilities to roles, you&#8217;re going to need a role management plugin.  A good one to use is my <a href="http://wordpress.org/extend/plugins/members" title="Members WordPress plugin">Members plugin</a>.  You could code this if you wanted, but it&#8217;s a bit outside the scope of this tutorial.</p>
<p>What you need to do at this point is assign capabilities to the roles that should have them.  Just be careful not to give too much power to the wrong roles.</p>
<ul>
<li><code>publish_movies</code>: This allows a user to publish a movie.</li>
<li><code>edit_movies</code>: Allows editing of the user&#8217;s own movies but does not grant publishing permission.</li>
<li><code>edit_others_movies</code>: Allows the user to edit everyone else&#8217;s movies but not publish.</li>
<li><code>delete_movies</code>: Grants the ability to delete movies written by that user but not others&#8217; movies.</li>
<li><code>delete_others_movies</code>:  Capability to edit movies written by other users.</li>
<li><code>read_private_movies</code>:  Allows users to read private movies.</li>
<li><code>edit_movie</code>: Meta capability assigned by WordPress.  Do not give to any role.</li>
<li><code>delete_movie</code>: Meta capability assigned by WordPress.  Do not give to any role.</li>
<li><code>read_movie</code>: Meta capability assigned by WordPress.  Do not give to any role.</li>
</ul>
<p>Just to say it again:  it is important that you don&#8217;t assign those last three capabilities to any role.  These are our meta capabilities that we&#8217;ll be mapping in the next section.</p>
<h2>Mapping the meta capabilities</h2>
<p>This part is completely customizable.  What we&#8217;re doing here is filtering the <code>map_meta_cap</code> hook so we can do our own mapping.  What this means is that users will be granted meta capabilities on a per-post basis so they can do things like edit their own posts.</p>
<p>I&#8217;m going to keep it extremely simple and follow my notes from the previous section.  If you wanted, you could do all kinds of crazy things here.</p>
<p>You can simply drop the below in your plugin or theme&#8217;s <code>functions.php</code> (whichever you&#8217;re using) and be done with it.  It&#8217;ll follow the rules I set forth above.</p>
<pre><code>add_filter( 'map_meta_cap', 'my_map_meta_cap', 10, 4 );

function my_map_meta_cap( $caps, $cap, $user_id, $args ) {

	/* If editing, deleting, or reading a movie, get the post and post type object. */
	if ( 'edit_movie' == $cap || 'delete_movie' == $cap || 'read_movie' == $cap ) {
		$post = get_post( $args[0] );
		$post_type = get_post_type_object( $post->post_type );

		/* Set an empty array for the caps. */
		$caps = array();
	}

	/* If editing a movie, assign the required capability. */
	if ( 'edit_movie' == $cap ) {
		if ( $user_id == $post->post_author )
			$caps[] = $post_type->cap->edit_posts;
		else
			$caps[] = $post_type->cap->edit_others_posts;
	}

	/* If deleting a movie, assign the required capability. */
	elseif ( 'delete_movie' == $cap ) {
		if ( $user_id == $post->post_author )
			$caps[] = $post_type->cap->delete_posts;
		else
			$caps[] = $post_type->cap->delete_others_posts;
	}

	/* If reading a private movie, assign the required capability. */
	elseif ( 'read_movie' == $cap ) {

		if ( 'private' != $post->post_status )
			$caps[] = 'read';
		elseif ( $user_id == $post->post_author )
			$caps[] = 'read';
		else
			$caps[] = $post_type->cap->read_private_posts;
	}

	/* Return the capabilities required by the user. */
	return $caps;
}</code></pre>
<h2>Now taking questions</h2>
<p>I realize there&#8217;s still quite a few things that I might not have covered in my tutorials on post types so far.  Some people have probably figured these out by now, but others of you may be stuck.</p>
<p>Feel free to ask any questions you have about post types, and I&#8217;ll see about answering them or writing more tutorials based on your suggestions.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom-post-types/feed</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Lowercase p, dangit!</title>
		<link>http://justintadlock.com/archives/2010/07/08/lowercase-p-dangit</link>
		<comments>http://justintadlock.com/archives/2010/07/08/lowercase-p-dangit#comments</comments>
		<pubDate>Thu, 08 Jul 2010 07:39:20 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Discussion]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2443</guid>
		<description><![CDATA[Why the <code>capital_P_dangit()</code> function is not only a bug but a detrimental blow to the WordPress community.]]></description>
			<content:encoded><![CDATA[<p>If you haven&#8217;t been following the latest hot debate in the WordPress community, you&#8217;re in for some news.  If you have been following it, you&#8217;re probably in a fiery rage, given up all hope in the &#8220;community&#8221; aspect of this community project, or are just sitting back laughing at the rest of us.</p>
<p><em>The issue</em>:  Before WordPress 3.0 was released, a small piece of code was added to the WordPress core that changes all instances of &#8220;Wordpress&#8221; (notice the lowercase &#8220;p&#8221;) to &#8220;WordPress&#8221; in areas where content is shown on the site.  We&#8217;ll get to the details in a bit.</p>
<p>I tried hard to stay out this debate because I&#8217;m fairly certain I made a vow to myself to stay out of these types of arguments.  But, I&#8217;ve got a few opinions on this one that I can&#8217;t just keep to myself.  And, as someone that is considered a <em>leader</em> within the WordPress community, I feel responsible for communicating with that community on this issue.</p>
<h2>It&#8217;s spelled &#8220;WordPress&#8221;</h2>
<p><a href="http://wpcamelcase.com/" title="WP CamelCase">WPCamelCase.com</a> says so, and I&#8217;d never question an entire site dedicated to the proper spelling of a single word.</p>
<p>On a more serious note, these are not proper:</p>
<ul>
<li>Wordpress</li>
<li>wordPress</li>
<li>wordpress</li>
<li>Word Press</li>
<li>word press</li>
<li>wordress</li>
<li>WoRdPrEsS</li>
</ul>
<p>Coming from an English and journalism (especially journalism) background, I feel a strong need to hack into the site of anyone that misspells WordPress and correct it for them.  Fortunately, I don&#8217;t know how to hack people&#8217;s sites, have just a smidgen of self control, and respect the rights of others.</p>
<h2>Why is there an issue?</h2>
<p>Matt Mullenweg wrote a filter function called <code>capital_P_dangit()</code> that correctly capitalizes the &#8220;P&#8221; in misspellings of WordPress where the &#8220;p&#8221; is lowercase.  It may seem like a minor thing, but there are several issues at hand.</p>
<ul>
<li>The code literally breaks things like URLs on some sites.  For example, suppose you installed WordPress in a <code>/Wordpress</code> directory.  That would cause all kinds of trouble with things like images.</li>
<li>This function is effectively changing what people write, and WordPress should not have editorial control over the content of anyone&#8217;s blog.</li>
<li>The code was <a href="http://core.trac.wordpress.org/changeset/14996" title="WordPress changeset: 14996">committed to WordPress</a> without a Trac ticket, so it wasn&#8217;t left open to community discussion beforehand.</li>
<li>Matt&#8217;s responses seem to dismiss the very community of people that help make WordPress what it is.</li>
</ul>
<h2>Following the discussion</h2>
<p>I cannot accurately represent all of the discussion that has happened to this point.  I highly recommend that you read the discussions provided by the below links if you want all the details.</p>
<ul>
<li><a href="http://core.trac.wordpress.org/ticket/13971" title="'Wordpress' being turned into CamelCase 'WordPress' breaks URLs">&#8220;Wordpress&#8221; being turned into CamelCase &#8220;WordPress&#8221; breaks URLs</a></li>
<li><a href="http://lists.automattic.com/pipermail/wp-hackers/2010-July/thread.html#32841" title="WP Hackers: July 2010: Putting the P in WordPress">Putting the P in WordPress: WP Hackers</a></li>
<li><a href="http://www.wptavern.com/automatically-correcting-the-wordpress-mistake" title="Automatically Correcting the WordPress Mistake">Automatically Correcting the WordPress Mistake</a></li>
<li><a href="http://www.wptavern.com/forum/general-wordpress/1745-wordpress-wordpress-core.html" title="Wordpress to WordPress in core?">Wordpress -> WordPress in core?</a></li>
<li><a href="http://hakre.wordpress.com/2010/07/07/wordpress-egomania/" title="MattPress Egomania">MattPress Egomania</a></li>
<li><a href="http://tomlany.net/2010/05/wordpress-to-wordpress/" title="Wordpress to WordPress">&#8220;Wordpress&#8221; to &#8220;WordPress&#8221; filter</a></li>
<li><a href="http://www.misthaven.org.uk/blog/2010/07/07/a-fuss-about-nothing/" title="A Fuss About Nothing">A Fuss About Nothing</a></li>
<li><a href="http://capitalp.org" title="The capital 'P' in WordPress caused the BP oil spill">CapitalP.org</a></li>
</ul>
<h2>Breaking URLs</h2>
<p>If nothing else, this issue must be addressed.  In fact, this bug was brought up in a <a href="http://core.trac.wordpress.org/ticket/13583" title="WordPress make WP contribute to drill baby drill">bug report</a> <em>before</em> WordPress 3.0 was released.  Yes, before.</p>
<p>The resolution set for this bug: <em>wontfix</em>.</p>
<p>A <a href="http://core.trac.wordpress.org/ticket/13971" title="'Wordpress' being turned into CamelCase 'WordPress' breaks URLs">new ticket</a> is now open for discussion and resolutions.  Mark Jaquith has at least created a patch that should fix this issue.</p>
<h2>Don&#8217;t change my content</h2>
<p>The <em>real</em> issue is not the bug; it&#8217;s the display of content that people didn&#8217;t write.  Sure, the cases where people actually intend to misspell WordPress are rare, but that&#8217;s besides the point.</p>
<p>The point is that the content is yours, and you should be able to write anything any way you see fit, including &#8220;WordPress.&#8221;</p>
<p>If you want to debate that last statement in any way, I suppose you can try all you want, but I can&#8217;t think of a single reason why a piece of software should be able to control the output of my words without consent.</p>
<p>We&#8217;re talking about principles here, and changing what people write in this manner goes against everything I believe in.  I simply refuse to allow this on my site.</p>
<p>One of the reasons I use WordPress is because of its philosophy on community, openness, and freedom, which fits along nicely with my own personal philosophy about most things in life.  The idea that a piece of software could infringe upon those values is what bothers people.</p>
<h2>What about emoticons and auto-paragraphs?</h2>
<p><em>What about apples and oranges?</em></p>
<p>This line of <em>reasoning</em> keeps getting brought up in the debate.</p>
<p>If you think the forced spelling of a word and the opt-in process of converting smileys and basic word-processing are one in the same, there&#8217;s no convincing you there&#8217;s an issue.  You may as well stop reading now.</p>
<h2>Why don&#8217;t you build a plugin?</h2>
<p>According to Matt Mullenweg, <a href="http://lists.automattic.com/pipermail/wp-hackers/2010-July/032900.html" title="WP Hackers July 2010: 032900">a plugin should be built</a>:</p>
<blockquote><p>
As I said before, you are in /complete control/ of your site. It&#8217;s a single line to remove a filter. If you don&#8217;t like the filter, vote with your feet or with a plugin.
</p></blockquote>
<p><em>Vote with your feet?</em>  This type of remark represents one of the biggest issues in the WordPress community.  Attitudes like this can bring down entire empires.</p>
<p>I completely agree with the plugin idea though.  Building plugins to gauge community interest in certain features and making the decision to include these plugins in core code based on statistics is a great idea.</p>
<p>As <a href="http://www.wptavern.com/automatically-correcting-the-wordpress-mistake" title="Automatically correcting the WordPress mistake">pointed out</a> by Jeff Chander, it just so happens that someone made a plugin nearly three years ago that does the same job as <code>capital_P_dangit()</code>.  It&#8217;s called <a href="http://wordpress.org/extend/plugins/ozhs-correctly-spell-wordpress/" title="Ozh' Correctly Spell WordPress plugin">Ozh&#8217; Correctly Spell WordPress</a>.</p>
<p>At the time of writing, this plugin has received a grand total of&#8230;wait for it&#8230;338 downloads!</p>
<p>As flawed as that argument is, a new plugin has been created called <a href="http://wordpress.org/extend/plugins/remove-wordpress-to-wordpress-filter" title="Remove Wordpress to WordPress Filter plugin">Remove Wordpress to WordPress Filter</a>  that disables the <code>capital_P_dangit()</code> functionality.  Funnily enough, its number of downloads will likely surpass the other plugin within a week or two given its current rate of adoption.</p>
<p>But, since we&#8217;re voting with plugins, there&#8217;ll be <a href="http://wordpress.org/extend/plugins/profile/greenshady" title="Justin Tadlock's plugins">16 other plugins</a> that will disable this filter soon enough.  All of my plugins will have this bug fix added to them in their next updates.</p>
<p>There&#8217;s two things that will make me reconsider this decision and remove this from my plugins:</p>
<ul>
<li>The <code>capital_P_dangit()</code> function is removed from the default filters or made to be opt-in.</li>
<li>An outcry of arguments from my plugin users to remove it.  Some of us <em>listen</em> to our users, even when we disagree with them.</li>
</ul>
<p class="alert">Since some folks have missed the point of this last argument, which I thought was clever (though I&#8217;m a bit biased), I must inject a note here to interrupt the flow of this article.  <strong>No</strong>, I don&#8217;t actually intend to update all 16 of my plugins to try and prove a point.  The entire point is to show how irrational such an action would be.</p>
<h2>How to remove the capital_P_dangit() filter</h2>
<p>You can either install the <a href="http://wordpress.org/extend/plugins/remove-wordpress-to-wordpress-filter" title="Remove Wordpress to WordPress Filter plugin">Remove Wordpress to WordPress Filter</a> plugin or add the below code to your theme&#8217;s <code>functions.php</code> file.</p>
<pre><code>remove_filter( 'the_content', 'capital_P_dangit' );
remove_filter( 'the_title', 'capital_P_dangit' );
remove_filter( 'comment_text', 'capital_P_dangit' );</code></pre>
<h2>Listen to your community</h2>
<p>I&#8217;ve only seen a handful of people that agree this function should be in WordPress.  It has been met with harsh opposition.  The people arguing to remove this function are people we need in the community.  They&#8217;re plugin developers, theme developers, contributors to core code, and evangelists for the WordPress platform.  These are the people that continue making WordPress better.</p>
<p>Don&#8217;t alienate them.</p>
<p>Are these people only a vocal minority of WordPress users?  Certainly.  However, these people speak for a larger amount of users.  For users without the knowledge of mailing lists.  For users without the understanding of how Trac works.  They are the people that interact with the majority every day.  They are the voice of the majority.</p>
<p>Don&#8217;t let their voices go unheard.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2010/07/08/lowercase-p-dangit/feed</wfw:commentRss>
		<slash:comments>106</slash:comments>
		</item>
	</channel>
</rss>
