<?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; WordPress</title>
	<atom:link href="http://justintadlock.com/topics/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://justintadlock.com</link>
	<description>Life, Blogging, and WordPress</description>
	<lastBuildDate>Mon, 06 Feb 2012 18:39:33 +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>Custom Classes: WordPress Plugin</title>
		<link>http://justintadlock.com/archives/2012/02/06/custom-classes-wordpress-plugin</link>
		<comments>http://justintadlock.com/archives/2012/02/06/custom-classes-wordpress-plugin#comments</comments>
		<pubDate>Mon, 06 Feb 2012 18:39:33 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=4459</guid>
		<description><![CDATA[The Custom Classes plugin allows you to add custom post and <code>&#60;body></code> classes on a per-post basis.]]></description>
			<content:encoded><![CDATA[<p>For a recent project, I needed a way to add custom post and body classes on a per-post basis.  Sure, I could have used a category or tag to style each post, but I hate creating custom categories and tags for the purposes of styling a post.  So, I created a small plugin to let me add custom classes for individual posts.</p>
<h2>How the plugin works</h2>
<p>The plugin adds a custom meta box on the edit post screen for any public post type called &#8220;Classes&#8221; as shown in the following screenshot.</p>
<p><img src="http://justintadlock.com/blog/wp-content/uploads/2012/02/screenshot-1.png" alt="Custom Classes meta box screenshot" title="Custom Classes meta box" width="600" height="423" class="aligncenter size-full" /></p>
<p>The meta box allows you to enter a custom class for a post (used by the <code>post_class()</code> function) or a custom body class (used by the <code>body_class()</code> function).</p>
<p>The following screenshot shows what your <code>&lt;body></code> class will look like in the source code on a single post.</p>
<p><img src="http://justintadlock.com/blog/wp-content/uploads/2012/02/screenshot-2.png" alt="Custom body class screenshot" title="Custom body class" width="600" height="184" class="aligncenter size-full" /></p>
<p>All you have to do is style your posts via <abbr title="Cascading Stylesheets">CSS</abbr> using the custom classes you&#8217;ve addded.</p>
<h2>Download the plugin</h2>
<p>You can download the latest version from the WordPress plugin repository: <a href="http://wordpress.org/extend/plugins/custom-classes" title="Custom Classes WordPress Plugin">Custom Classes Plugin</a>. I hope you enjoy it and find some use for it in your projects.</p>
<p class="note">Please do not ask support questions in the comments below. If you’re in need of plugin support, head over to the Theme Hybrid <a href="http://themehybrid.com/support" title="Theme Hybrid Support">support forums</a>, which is where I handle support for all my plugins and themes.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2012/02/06/custom-classes-wordpress-plugin/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>One multi-task plugin vs. several single-task plugins?</title>
		<link>http://justintadlock.com/archives/2012/01/21/one-massive-plugin-vs-several-mini-plugins</link>
		<comments>http://justintadlock.com/archives/2012/01/21/one-massive-plugin-vs-several-mini-plugins#comments</comments>
		<pubDate>Sat, 21 Jan 2012 14:57:47 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Discussion]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=4447</guid>
		<description><![CDATA[Would you rather use larger plugins with multiple functions or smaller plugins that handle single tasks?]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve been giving a lot of thought to the debate over whether it&#8217;s better to develop larger plugins that handle many related tasks or smaller, mini-plugins that handle extremely specific tasks.  There&#8217;s merit to both arguments, but I wanted to give my readers a chance to discuss this and help me come to a decision about how I developer some of my future plugins.</p>
<p>The biggest reason for this article is that I&#8217;ve been trying to make a final decision on how one (or multiple as the case may be) of my plugins will be developed.  Other plugin developers might also find this discussion useful in helping them make decisions.</p>
<h2>The example plugin</h2>
<p>I want you to have an example of what I&#8217;m asking you to discuss, so I&#8217;ll give you a few details on the plugin(s) I&#8217;m developing.  It is a set of extensions to how comments are handled in WordPress.  Some of these extensions include:</p>
<ul>
<li>Moderate all non-Enlish comments.</li>
<li>Automatically delete spam on a schedule.</li>
<li>Turn on/off comments for specific post types by default (like with posts).</li>
<li>Moderate all trackbacks and pingbacks.</li>
<li>And more.</li>
</ul>
<p>The plugin currently has several options like the above.  Basically, it&#8217;s just an extension to the &#8220;Discussion Settings&#8221; page in the WordPress admin.  It&#8217;s easy to see how some users might only want to use one or two of those settings rather than all of them.</p>
<h2>Advantages of a single, multi-task plugin</h2>
<p>The following is a list of some of the advantages to running a single plugin:</p>
<ul>
<li>You only have to run one plugin.  Many people live in fear of running &#8220;too many plugins&#8221; because it might somehow break their site.  Realistically, running too many large or poorly-coded plugins would be more of a problem.  While you can&#8217;t really have too many plugins, this fear from users is something to consider.</li>
<li>Fewer things to manage.  No one likes to update plugins every day.  The more plugins you have, the more likely you&#8217;ll have to update them frequently.  Having to only update a single plugin instead of several is easier.</li>
<li>Fewer translation files.  Translators would only have to update and maintain a single translation file for one plugin as opposed to multiple translations for multiple plugins.</li>
</ul>
<h2>Advantages of multiple, single-task plugins</h2>
<p>The list below is some of the advantages of using several plugins.</p>
<ul>
<li>You don&#8217;t have to load code you don&#8217;t need.  Using mini plugins means that you only have to load and run code that you absolutely want.  With a single plugin, there may be several parts of the plugin that you don&#8217;t want to use.</li>
<li>There&#8217;s generally fewer bugs.  Less code in a plugin means there&#8217;s less chance of bugs arising.  It also makes it easier to find and fix bugs more quickly.  Thus, allowing plugin developers to quickly get out new releases when they&#8217;re needed.</li>
<li>Fewer database options.  With multiple plugins, sometimes you don&#8217;t need an option at all.  The plugin simply works.  With a single, large plugin, each setting might need to be enabled/disabled.</li>
</ul>
<h2>What are your thoughts?</h2>
<p>Think about the example plugin I mentioned early in the post.  If I allowed you to make the final decision on whether you&#8217;d like to see this developed as a single plugin or multiple plugins, which would you choose?</p>
<p>Now, think about the plugins you currently have installed on your site.  Are there some that you&#8217;d like to see broken down into smaller plugins that only handled specific tasks?</p>
<p>Are there any other advantages or disadvantages you&#8217;d like to share?</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2012/01/21/one-massive-plugin-vs-several-mini-plugins/feed</wfw:commentRss>
		<slash:comments>73</slash:comments>
		</item>
		<item>
		<title>Prevent Password Reset WordPress Plugin</title>
		<link>http://justintadlock.com/archives/2012/01/19/prevent-password-reset-wordpress-plugin</link>
		<comments>http://justintadlock.com/archives/2012/01/19/prevent-password-reset-wordpress-plugin#comments</comments>
		<pubDate>Thu, 19 Jan 2012 19:36:15 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=4434</guid>
		<description><![CDATA[A plugin that allows you to disable password resetting via the "lost password" form on a per-user basis.]]></description>
			<content:encoded><![CDATA[<p>Recently, I needed to build some functionality into a site that disabled the ability to reset the passwords of certain site administrators via the &#8220;lost password&#8221; form.  However, I wanted to leave this option open for other users in case they needed to reset their password after forgetting it.  </p>
<p>Thus, the Prevent Password Reset plugin was born.</p>
<h2>How the plugin works</h2>
<p>Prevent Password Reset is an extremely simple plugin.  It adds a checkbox to the &#8220;Personal Options&#8221; section of each user&#8217;s profile page in the WordPress admin as shown in the following screenshot.  Anyone who can edit the user&#8217;s profile can select this option for the user.</p>
<p><img src="http://justintadlock.com/blog/wp-content/uploads/2012/01/password-reset-profile-page.png" alt="Screenshot of password reset option on user profile page" title="User Personal Options: Password Reset" width="600" height="384" class="aligncenter size-full wp-image-4436" /></p>
<p>Once this option is selected for a user, their password cannot be reset via the &#8220;lost password&#8221; form.  The following screenshot shows what happens when someone attempts to reset the password for a user with password preventing enabled.</p>
<p><img src="http://justintadlock.com/blog/wp-content/uploads/2012/01/password-reset-disabled.png" alt="Screenshot of password reset disabled" title="Password Reset Disabled" width="600" height="447" class="aligncenter size-full wp-image-4437" /></p>
<h2>Download the plugin</h2>
<p>You can download the latest version from the WordPress plugin repository:  <a href="http://wordpress.org/extend/plugins/prevent-password-reset" title="Prevent Password Reset: WordPress Plugin">Prevent Password Reset Plugin</a>.  I hope you enjoy it and can get some type of use out of it.</p>
<p class="alert">Please do not ask support questions in the comments below.  If you&#8217;re in need of plugin support, head over to the Theme Hybrid <a href="http://themehybrid.com/support" title="Theme Hybrid Support">support forums</a>, which is where I handle support for all my plugins and themes.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2012/01/19/prevent-password-reset-wordpress-plugin/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>WordCamp Birmingham 2012</title>
		<link>http://justintadlock.com/archives/2012/01/10/wordcamp-birmingham-2012</link>
		<comments>http://justintadlock.com/archives/2012/01/10/wordcamp-birmingham-2012#comments</comments>
		<pubDate>Wed, 11 Jan 2012 02:47:12 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordCamp]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=4423</guid>
		<description><![CDATA[I&#8217;ll be attending WordCamp Birmingham this upcoming weekend (Jan. 14&#8211;15, 2012). I&#8217;d love to meet some of you fine folks from the WordPress community, so I hope y&#8217;all are coming! So, if you want to get together for a beer or something let me know.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be attending <a href="http://wpyall.com" title="WordCamp Birmingham">WordCamp Birmingham</a> this upcoming weekend (Jan. 14&ndash;15, 2012).  I&#8217;d love to meet some of you fine folks from the WordPress community, so I hope y&#8217;all are coming!  So, if you want to get together for a beer or something let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2012/01/10/wordcamp-birmingham-2012/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Pre-order WPCandy Quarterly #1</title>
		<link>http://justintadlock.com/archives/2011/12/16/pre-order-wpcandy-quarterly-1</link>
		<comments>http://justintadlock.com/archives/2011/12/16/pre-order-wpcandy-quarterly-1#comments</comments>
		<pubDate>Fri, 16 Dec 2011 21:21:08 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=4410</guid>
		<description><![CDATA[If you&#8217;re a WordPress enthusiast, I highly recommend pre-ordering issue #1 of the WPCandy Quarterly, a print magazine for us WordPress folks. There will be quite a few interesting articles. Plus, I&#8217;m one of the authors in the first issue.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re a WordPress enthusiast, I highly recommend pre-ordering issue #1 of the <a href="http://wpcandy.com/quarterly" title="WPCandy Quarterly">WPCandy Quarterly</a>, a print magazine for us WordPress folks.  There will be quite a few interesting articles.  Plus, I&#8217;m one of the authors in the first issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2011/12/16/pre-order-wpcandy-quarterly-1/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>What&#8217;s going on with DevPress?</title>
		<link>http://justintadlock.com/archives/2011/12/13/whats-going-on-with-devpress</link>
		<comments>http://justintadlock.com/archives/2011/12/13/whats-going-on-with-devpress#comments</comments>
		<pubDate>Wed, 14 Dec 2011 00:31:08 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[DevPress]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=4404</guid>
		<description><![CDATA[The story behind why the DevPress team is splitting up and what this means for the future.]]></description>
			<content:encoded><![CDATA[<p>For those of you who don&#8217;t know about <a href="http://devpress.com" title="DevPress">DevPress</a>, have you been living under a rock?  Seriously, it is a WordPress business I began with Tung Do, Patrick Daly, and Ptah Dunbar.  All of these guys are awesome at what they do and are great folks to work with.</p>
<p>The main goal of DevPress was to build an awesome WordPress plugin and theme community where everyone was welcome (and a lot more!).  Unfortunately, things didn&#8217;t go as planned in these past six months or so.  Therefore, we had to make some tough decisions.  In the end, Tung became the sole owner of DevPress.</p>
<p>Tung described our problem best in his <a href="http://devpress.com/blog/a-step-back-for-the-team-a-step-forward-for-devpress/" title="A Step Back for the Team, A Step Forward for DevPress">official update</a> on the DevPress blog:</p>
<blockquote><p>
DevPress managed to release high quality products and tease the community of buzz-worthy ideas, but what we needed most was consistency. If success is 80% just simply showing up well then we failed.
</p></blockquote>
<p>DevPress team members were all over the place.  We never had everyone on the same page at the same time.  We had too many ideas and projects that started but never got finished.  This is a problem when you&#8217;re trying to kick-start a business venture.</p>
<p>The other issue that we ran into is the <em>too-many-chiefs-not-enough-Indians</em> scenario.  Since we were all four the owners of the site (equal ownership), each decision had to be agreed upon.  For those of you starting up your own business, take my advice:  Elect a single shot-caller, one person to make most of the decisions and manage day-to-day operations.  Bigger decisions can be made as a team, but smaller things need to be decided upon in a timely fashion so you can move on to the next thing you need to work on.</p>
<p>Tung will be moving forward with some great ideas he&#8217;s had for a long time.  I&#8217;m happy he&#8217;s getting a chance to see them through.</p>
<p>Just so you don&#8217;t get any tabloid-like ideas about &#8220;what really happened,&#8221; just know that we&#8217;re all parting as friends.  DevPress is changing directions because it was the best move for the business and the WordPress community.  </p>
<p>I don&#8217;t feel like I&#8217;ve lost anything.  I feel like I&#8217;ve made three great friends who I can rely on.  Don&#8217;t be surprised if you find two or more of us working together in the future.</p>
<h2>What does this mean for me?</h2>
<p>For starters, JustinTadlock.com is once again the home of my WordPress tutorials.  You can now find all of the tutorials I wrote for DevPress in the <a href="http://justintadlock.com/topics/wordpress" title="WordPress Topics">WordPress section</a> of this blog.</p>
<p><a href="http://themehybrid.com" title="Theme Hybrid Community">Theme Hybrid</a> members are getting a few plugins (DevPress plugins and unreleased plugins) as well as the <a href="http://themehybrid.com/themes/news" title="News WordPress theme">News theme</a>.  I&#8217;ll be keeping members updated as I continue moving stuff over to the site.</p>
<p>Outside of that, it&#8217;ll be the same ol&#8217;, same ol&#8217;.  I&#8217;ll just continue breaking WordPress while trying to do cool things with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2011/12/13/whats-going-on-with-devpress/feed</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>WordPress 3.3: Sonny</title>
		<link>http://justintadlock.com/archives/2011/12/12/wordpress-3-3-sonny</link>
		<comments>http://justintadlock.com/archives/2011/12/12/wordpress-3-3-sonny#comments</comments>
		<pubDate>Tue, 13 Dec 2011 00:02:08 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=4401</guid>
		<description><![CDATA[All the awesomeness that is WordPress 3.3 is finally here. Go ahead a grab a copy of the new version and have fun! I&#8217;m just thankful that we&#8217;ve got plenty of time to play around with it before Christmas.]]></description>
			<content:encoded><![CDATA[<p>All the awesomeness that is WordPress 3.3 is finally here.  Go ahead a <a href="http://wordpress.org/news/2011/12/sonny/" title="WordPress 3.3: Sonny">grab a copy of the new version</a> and have fun!  I&#8217;m just thankful that we&#8217;ve got plenty of time to play around with it before Christmas.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2011/12/12/wordpress-3-3-sonny/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>My Life theme testing</title>
		<link>http://justintadlock.com/archives/2011/11/24/my-life-theme-testing</link>
		<comments>http://justintadlock.com/archives/2011/11/24/my-life-theme-testing#comments</comments>
		<pubDate>Thu, 24 Nov 2011 13:23:29 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Themes]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=3263</guid>
		<description><![CDATA[I&#8217;m currently testing out the My Life theme here on my blog. If you&#8217;re a member of Theme Hybrid, you can grab a beta copy of it from the Theme Hybrid forums to play around with it before release.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently testing out the <em>My Life</em> theme here on my blog.  If you&#8217;re a member of Theme Hybrid, you can grab a beta copy of it from the <a href="http://themehybrid.com/support" title="Theme Hybrid support forums">Theme Hybrid forums</a> to play around with it before release.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2011/11/24/my-life-theme-testing/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Custom user taxonomies in WordPress</title>
		<link>http://justintadlock.com/archives/2011/10/20/custom-user-taxonomies-in-wordpress</link>
		<comments>http://justintadlock.com/archives/2011/10/20/custom-user-taxonomies-in-wordpress#comments</comments>
		<pubDate>Thu, 20 Oct 2011 18:45:31 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://devpress.com/?p=4267</guid>
		<description><![CDATA[How to create, manage, and use a custom taxonomy for users (not posts) in WordPress.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re at all familiar with taxonomies in WordPress, you already know how awesome it is to add custom taxonomies to your posts or custom post types.  WordPress developers have known this for a while.</p>
<p>What many people don&#8217;t know is that the current taxonomy schema was added way <a href="http://ryan.boren.me/2007/08/26/wordpress-23-taxonomy-schema/" title="WordPress 2.3 taxonomy schema">back in WordPress 2.3</a>.  Yes, that means the ability to create and use custom taxonomies has been around since 2007.  We didn&#8217;t get all the cool functions added until 2.8 though.</p>
<p>However, one thing we&#8217;ve had since 2.3 was the ability to create taxonomies for any object type, not just posts.  In WordPress, there are several object types:</p>
<ul>
<li>Posts</li>
<li>Users</li>
<li>Comments</li>
<li>Links</li>
</ul>
<p>So, you can technically create a taxonomy for any object type.  Most of WordPress core support is for posts, but the API is extremely well thought out and can handle the other object types with minimal code effort.</p>
<p>This tutorial will focus on registering and using a taxonomy on the user object type.  It will not be a 100% solution for everything you can do with a custom user taxonomy.  Consider this an extremely rough draft of what&#8217;s possible.</p>
<p>Because this is such an in-depth topic, I cannot explain every minute detail.  That would make for about a 50-page tutorial.  You&#8217;ll need to be familiar with a few key areas in WordPress development before proceeding:  plugins, themes, users, and taxonomies.</p>
<h2>Registering a user taxonomy</h2>
<p>In this tutorial, you will use and register a taxonomy called &#8220;Profession.&#8221;  This is just an example, so feel free to experiment and create your own taxonomies for your uses.</p>
<p>To register the user taxonomy, you use the <a href="http://codex.wordpress.org/Function_Reference/register_taxonomy" title="WordPress Codex: register_taxonomy()">register_taxonomy()</a> function just like you would with any other taxonomy.  The following code block will register the profession taxonomy and set up its arguments.</p>
<pre><code>/**
 * Registers the 'profession' taxonomy for users.  This is a taxonomy for the 'user' object type rather than a
 * post being the object type.
 */
function my_register_user_taxonomy() {

	 register_taxonomy(
		'profession',
		'user',
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Professions' ),
				'singular_name' => __( 'Profession' ),
				'menu_name' => __( 'Professions' ),
				'search_items' => __( 'Search Professions' ),
				'popular_items' => __( 'Popular Professions' ),
				'all_items' => __( 'All Professions' ),
				'edit_item' => __( 'Edit Profession' ),
				'update_item' => __( 'Update Profession' ),
				'add_new_item' => __( 'Add New Profession' ),
				'new_item_name' => __( 'New Profession Name' ),
				'separate_items_with_commas' => __( 'Separate professions with commas' ),
				'add_or_remove_items' => __( 'Add or remove professions' ),
				'choose_from_most_used' => __( 'Choose from the most popular professions' ),
			),
			'rewrite' => array(
				'with_front' => true,
				'slug' => 'author/profession' // Use 'author' (default WP user slug).
			),
			'capabilities' => array(
				'manage_terms' => 'edit_users', // Using 'edit_users' cap to keep this simple.
				'edit_terms'   => 'edit_users',
				'delete_terms' => 'edit_users',
				'assign_terms' => 'read',
			),
			'update_count_callback' => 'my_update_profession_count' // Use a custom function to update the count.
		)
	);
}</code></pre>
<p>I won&#8217;t cover all the arguments used in the code above.  I&#8217;ve written about those in a <a href="http://justintadlock.com/archives/2010/06/10/a-refresher-on-custom-taxonomies" title="A refresher on custom taxonomies">previous tutorial</a>.  However, there are a few arguments you should pay careful attention to:</p>
<ul>
<li><strong>rewrite['slug']:</strong>  I used <code>author/profession</code> so that the slug would fall in line with the WordPress user slug, <code>author</code>.  We&#8217;ll need a slight fix for this too, which I&#8217;ll get to later in the tutorial.</li>
<li><strong>capabilities:</strong>  For simplicity, I&#8217;ve set most of the capabilities to <code>edit_users</code>.  Only administrators can manage, edit, and delete professions with this by default.  The <code>assign_terms</code> capability is set to <code>read</code> so all users can edit this on their profile page.  You&#8217;ll want to set up some custom capabilities or configure this to do what you want.</li>
<li><strong>update_count_callback:</strong>  You must use a custom function for this because WordPress expects the taxonomy to be for the post object type.</li>
</ul>
<p>Once you&#8217;ve registered your taxonomy, WordPress really doesn&#8217;t do much for you.  It won&#8217;t add any custom admin pages, meta boxes, or anything of the sort like it does for posts.  That&#8217;ll be left up to you.</p>
<h2>Custom term update count callback</h2>
<p>Right off the bat, you&#8217;ll already need some custom code.  Since WordPress will only update the term counts for taxonomies on posts, you&#8217;ll need a function to do this for users.</p>
<p>When you registered your taxonomy, you set the <code>update_count_callback</code> argument to <code>my_update_profession_count</code>.  The following code is that callback function.</p>
<pre><code>/**
 * Function for updating the 'profession' taxonomy count.  What this does is update the count of a specific term
 * by the number of users that have been given the term.  We're not doing any checks for users specifically here.
 * We're just updating the count with no specifics for simplicity.
 *
 * See the _update_post_term_count() function in WordPress for more info.
 *
 * @param array $terms List of Term taxonomy IDs
 * @param object $taxonomy Current taxonomy object of terms
 */
function my_update_profession_count( $terms, $taxonomy ) {
	global $wpdb;

	foreach ( (array) $terms as $term ) {

		$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term ) );

		do_action( 'edit_term_taxonomy', $term, $taxonomy );
		$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
		do_action( 'edited_term_taxonomy', $term, $taxonomy );
	}
}</code></pre>
<p>I just kept this extremely simple and modified the <code>_update_post_term_count()</code> WordPress function.  Feel free to further modify it to suit your needs.</p>
<h2>Creating the manage terms page</h2>
<p><img src="http://justintadlock.com/blog/wp-content/uploads/2011/10/manage-professions.png" alt="Manage user taxonomy terms admin page" title="Custom user taxonomy admin page" width="600" height="341" class="aligncenter size-full wp-image-4272" /></p>
<p>Since WordPress does not create an admin page for managing terms of custom user taxonomies, you&#8217;ll need to create that.  For the sake of simplicity and laziness, I just used the admin page WordPress already uses for other taxonomies.  </p>
<p>The problem with this is that WordPress doesn&#8217;t recognize that the &#8220;Professions&#8221; admin page is a sub-menu of the &#8220;Users&#8221; admin page when viewing it.  The sub-menu is placed correctly, but when clicking on it, the &#8220;Posts&#8221; menu is opened in the admin.  I&#8217;d really love to see some WordPress core support for this.</p>
<p class="alert"><strong>Update:</strong>  See the <a href="http://justintadlock.com/archives/2011/10/20/custom-user-taxonomies-in-wordpress#comment-568682">comment by James</a> below to get a fix for this.</p>
<p>The following code is what I used, but you can definitely create a custom admin page for managing your terms.</p>
<pre><code>/* Adds the taxonomy page in the admin. */
add_action( 'admin_menu', 'my_add_profession_admin_page' );

/**
 * Creates the admin page for the 'profession' taxonomy under the 'Users' menu.  It works the same as any
 * other taxonomy page in the admin.  However, this is kind of hacky and is meant as a quick solution.  When
 * clicking on the menu item in the admin, WordPress' menu system thinks you're viewing something under 'Posts'
 * instead of 'Users'.  We really need WP core support for this.
 */
function my_add_profession_admin_page() {

	$tax = get_taxonomy( 'profession' );

	add_users_page(
		esc_attr( $tax->labels->menu_name ),
		esc_attr( $tax->labels->menu_name ),
		$tax->cap->manage_terms,
		'edit-tags.php?taxonomy=' . $tax->name
	);
}</code></pre>
<p>This will at least allow you to create and manage custom terms of the profession taxonomy.  If you have a better solution for this, please post it in the comments for other people to see.</p>
<h3>Fixing the &#8220;Posts&#8221; column</h3>
<p>After creating the admin page, you probably noticed a column on it called &#8220;Posts.&#8221;  Instead, it should display a &#8220;Users&#8221; column.  The following code will fix this issue and list the number of users with each term from the profession taxonomy.</p>
<pre><code>/* Create custom columns for the manage profession page. */
add_filter( 'manage_edit-profession_columns', 'my_manage_profession_user_column' );

/**
 * Unsets the 'posts' column and adds a 'users' column on the manage profession admin page.
 *
 * @param array $columns An array of columns to be shown in the manage terms table.
 */
function my_manage_profession_user_column( $columns ) {

	unset( $columns['posts'] );

	$columns['users'] = __( 'Users' );

	return $columns;
}

/* Customize the output of the custom column on the manage professions page. */
add_action( 'manage_profession_custom_column', 'my_manage_profession_column', 10, 3 );

/**
 * Displays content for custom columns on the manage professions page in the admin.
 *
 * @param string $display WP just passes an empty string here.
 * @param string $column The name of the custom column.
 * @param int $term_id The ID of the term being displayed in the table.
 */
function my_manage_profession_column( $display, $column, $term_id ) {

	if ( 'users' === $column ) {
		$term = get_term( $term_id, 'profession' );
		echo $term->count;
	}
}</code></pre>
<h2>Assigning terms to users</h2>
<p>Thus far, you&#8217;ve got a custom taxonomy and can add terms for it, but you need a way to assign these terms to individual users.  For this example, you&#8217;ll be adding a custom section to the edit user/profile page in the admin.  It will display a list of radio select boxes so the user can choose their profession.</p>
<p>This is just an extremely basic example.  You have tons of room for customization.  You can do select elements, checkboxes, a text input, or whatever best works for you.</p>
<p>The following PHP code will add this section to the edit user/profile page.</p>
<pre><code>/* Add section to the edit user page in the admin to select profession. */
add_action( 'show_user_profile', 'my_edit_user_profession_section' );
add_action( 'edit_user_profile', 'my_edit_user_profession_section' );

/**
 * Adds an additional settings section on the edit user/profile page in the admin.  This section allows users to
 * select a profession from a checkbox of terms from the profession taxonomy.  This is just one example of
 * many ways this can be handled.
 *
 * @param object $user The user object currently being edited.
 */
function my_edit_user_profession_section( $user ) {

	$tax = get_taxonomy( 'profession' );

	/* Make sure the user can assign terms of the profession taxonomy before proceeding. */
	if ( !current_user_can( $tax->cap->assign_terms ) )
		return;

	/* Get the terms of the 'profession' taxonomy. */
	$terms = get_terms( 'profession', array( 'hide_empty' => false ) ); ?>

	&lt;h3>&lt;?php _e( 'Profession' ); ?>&lt;/h3>

	&lt;table class="form-table">

		&lt;tr>
			&lt;th>&lt;label for="profession">&lt;?php _e( 'Select Profession' ); ?>&lt;/label>&lt;/th>

			&lt;td>&lt;?php

			/* If there are any profession terms, loop through them and display checkboxes. */
			if ( !empty( $terms ) ) {

				foreach ( $terms as $term ) { ?>
					&lt;input type="radio" name="profession" id="profession-&lt;?php echo esc_attr( $term->slug ); ?>" value="&lt;?php echo esc_attr( $term->slug ); ?>" &lt;?php checked( true, is_object_in_term( $user->ID, 'profession', $term ) ); ?> /> &lt;label for="profession-&lt;?php echo esc_attr( $term->slug ); ?>">&lt;?php echo $term->name; ?>&lt;/label> &lt;br />
				&lt;?php }
			}

			/* If there are no profession terms, display a message. */
			else {
				_e( 'There are no professions available.' );
			}

			?>&lt;/td>
		&lt;/tr>

	&lt;/table>
&lt;?php }</code></pre>
<p>After adding the preceding code, you&#8217;ll get a new section near the bottom of your edit user/profile page that looks like the following screenshot.</p>
<p><img src="http://justintadlock.com/blog/wp-content/uploads/2011/10/edit-user-profession.png" alt="Assigning taxonomy terms on user profile page" title="Edit user profile with taxonomy" width="600" height="191" class="aligncenter size-full wp-image-4272" /></p>
<p>You&#8217;ll need a way to save the selected term (profession) for the user.  The next code block will handle that.</p>
<pre><code>/* Update the profession terms when the edit user page is updated. */
add_action( 'personal_options_update', 'my_save_user_profession_terms' );
add_action( 'edit_user_profile_update', 'my_save_user_profession_terms' );

/**
 * Saves the term selected on the edit user/profile page in the admin. This function is triggered when the page
 * is updated.  We just grab the posted data and use wp_set_object_terms() to save it.
 *
 * @param int $user_id The ID of the user to save the terms for.
 */
function my_save_user_profession_terms( $user_id ) {

	$tax = get_taxonomy( 'profession' );

	/* Make sure the current user can edit the user and assign terms before proceeding. */
	if ( !current_user_can( 'edit_user', $user_id ) &#038;&#038; current_user_can( $tax->cap->assign_terms ) )
		return false;

	$term = esc_attr( $_POST['profession'] );

	/* Sets the terms (we're just using a single term) for the user. */
	wp_set_object_terms( $user_id, array( $term ), 'profession', false);

	clean_object_term_cache( $user_id, 'profession' );
}</code></pre>
<h2>Displaying user taxonomy terms</h2>
<p>You can use any of the standard WordPress taxonomy functions for listing out your terms.  For example, <a href="http://codex.wordpress.org/Function_Reference/wp_list_categories" title="WordPress Codex: wp_list_categories()">wp_list_categories()</a> and <a href="http://codex.wordpress.org/Function_Reference/wp_tag_cloud" title="WordPress Codex: wp_tag_cloud()">wp_tag_cloud()</a> will both work fine.  Each will link to the term archive page (covered in the section below).</p>
<p>If you wanted to show a tag cloud with all of your &#8220;professions&#8221; (profession cloud) in a theme template, your code would look something like the following.</p>
<pre><code>&lt;?php wp_tag_cloud( array( 'taxonomy' => 'profession' ) ); ?></code></pre>
<p>One thing to look out for though is that the <code>title</code> attribute for links in the tag cloud will read &#8220;1 topic&#8221; or &#8220;X topics.&#8221;  An easy way to change this is to write a custom callback function to modify the text.  In the following screenshot, you can see this changed from &#8220;topics&#8221; to &#8220;users&#8221;.</p>
<p><img src="http://justintadlock.com/blog/wp-content/uploads/2011/10/user-term-tooltip.png" alt="Tooltip changed to &#039;users&#039; on term archive link" title="Topic count callback tooltip" width="600" height="120" class="aligncenter size-full wp-image-4271" /></p>
<p>The following code block is a function that will handle that.</p>
<pre><code>/**
 * Function for outputting the correct text in a tag cloud.  Use as the 'update_topic_count_callback' argument
 * when calling wp_tag_cloud().  Instead of 'topics' it displays 'users'.
 *
 * @param int $count The count of the objects for the term.
 */
function my_profession_count_text( $count ) {
	return sprintf( _n('%s user', '%s users', $count ), number_format_i18n( $count ) );
}</code></pre>
<p>You&#8217;d use it when displaying your tag cloud like so:</p>
<pre><code>&lt;?php wp_tag_cloud(
	array(
		'taxonomy' => 'profession',
		'topic_count_text_callback' => 'my_profession_count_text'
	)
); ?></code></pre>
<h2>Templates for term archives</h2>
<p><a href="http://justintadlock.com/blog/wp-content/uploads/2011/10/user-tax-screenshot.png"><img src="http://justintadlock.com/blog/wp-content/uploads/2011/10/user-tax-screenshot-265x300.png" alt="User taxonomy archive page" title="Term archive page of users" width="265" height="300" class="alignright size-medium wp-image-4270" /></a></p>
<p>The <a href="http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display" title="WordPress Codex: Template Hierarchy: Taxonomy">template for term archives</a> is handled the same as any other taxonomy.  So, if you wanted to create a custom template (you probably should) for your theme to display users by profession, you&#8217;ll want to create a template named <code>taxonomy-profession.php</code>.</p>
<p>I won&#8217;t cover creating theme templates here.  It&#8217;s outside the scope of this tutorial.  </p>
<p>The big difference between this template and a normal template is there&#8217;s no post loop.  Instead, you need to create a user loop.  The following code should replace your normal post loop in this template.</p>
<pre><code>&lt;?php
$term_id = get_queried_object_id();
$term = get_queried_object();

$users = get_objects_in_term( $term_id, $term->taxonomy );

if ( !empty( $users ) ) {
?>
	&lt;?php foreach ( $users as $user_id ) { ?>

		&lt;div class="user-entry">
			&lt;?php echo get_avatar( get_the_author_meta( 'email', $user_id ), '96' ); ?>
			&lt;h2 class="user-title">&lt;a href="&lt;?php echo esc_url( get_author_posts_url( $user_id ) ); ?>">&lt;?php the_author_meta( 'display_name', $user_id ); ?>&lt;/a>&lt;/h2>

			&lt;div class="description">
				&lt;?php echo wpautop( get_the_author_meta( 'description', $user_id ) ); ?>
			&lt;/div>
		&lt;/div>

	&lt;?php } ?>
&lt;?php } ?></code></pre>
<p>The most important function used in the code above is the WordPress <a href="http://codex.wordpress.org/Function_Reference/get_objects_in_term" title="WordPress Codex: get_objects_in_term()">get_objects_in_term()</a> function.  By putting in a term ID and taxonomy name, you can grab an array of all the object (user) IDs with that term (profession).  With the user ID, you can load any information about a user you want with any standard WordPress functions.</p>
<p>Of course, you&#8217;re free to customize this however you want.  The preceding code merely loops through each of the users with a specific profession.  It then displays each user&#8217;s avatar, name with a link to their posts archive, and description.</p>
<h2>Disabling the &#8216;profession&#8217; username</h2>
<p>When you registered the profession taxonomy, you created the slug <code>author/profession</code> so that the profession archive pages would have a URL like <code>yoursite.com/author/profession/designer</code>.  The problem with this that &#8220;profession&#8221; could potentially be a username someone signs up to your site with.</p>
<p>The following code will make sure no one can sign up with this username:</p>
<pre><code>/* Filter the 'sanitize_user' to disable username. */
add_filter( 'sanitize_user', 'my_disable_username' );

/**
 * Disables the 'profession' username when someone registers.  This is to avoid any conflicts with the custom
 * 'author/profession' slug used for the 'rewrite' argument when registering the 'profession' taxonomy.  This
 * will cause WordPress to output an error that the username is invalid if it matches 'profession'.
 *
 * @param string $username The username of the user before registration is complete.
 */
function my_disable_username( $username ) {

	if ( 'profession' === $username )
		$username = '';

	return $username;
}</code></pre>
<p>Of course, if you use a different rewrite structure for your taxonomy, don&#8217;t worry about that code.</p>
<h2>Time to create your own user taxonomies</h2>
<p>Whoah!  That was certainly a ton of information to cover in a single tutorial.  I&#8217;m sure some of you have questions, so please ask away in the comments.</p>
<p>Now it&#8217;s time for you to venture out on your own and create some cool stuff.  I&#8217;d love to hear what ideas you have and see any projects that you use this code in.  I&#8217;m definitely interested in seeing some practical, real-world use cases of user taxonomies.</p>
<p>One final note:  The code in this tutorial is just something I played around with in about a two-hour span.  It&#8217;s still a work in progress.  Honestly, it took me much longer to write this tutorial.  Therefore, I leave it up to you, dear reader, to improve upon the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2011/10/20/custom-user-taxonomies-in-wordpress/feed</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>How to create custom post meta boxes</title>
		<link>http://justintadlock.com/archives/2011/10/06/how-to-create-custom-post-meta-boxes</link>
		<comments>http://justintadlock.com/archives/2011/10/06/how-to-create-custom-post-meta-boxes#comments</comments>
		<pubDate>Thu, 06 Oct 2011 20:40:05 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[Asides]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=3226</guid>
		<description><![CDATA[My first post on Smashing WordPress is up: How to create custom post meta boxes.]]></description>
			<content:encoded><![CDATA[<p>My first post on Smashing WordPress is up: <a href="http://wp.smashingmagazine.com/2011/10/04/create-custom-post-meta-boxes-wordpress/" title="How to create custom post meta boxes: Smashing Magazine">How to create custom post meta boxes</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2011/10/06/how-to-create-custom-post-meta-boxes/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

