<?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/tags/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://justintadlock.com</link>
	<description>Life, Blogging, and WordPress</description>
	<lastBuildDate>Sun, 07 Feb 2010 08:25:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>It&#8217;s the little things that matter</title>
		<link>http://justintadlock.com/archives/2010/02/07/its-the-little-things-that-matter</link>
		<comments>http://justintadlock.com/archives/2010/02/07/its-the-little-things-that-matter#comments</comments>
		<pubDate>Sun, 07 Feb 2010 08:25:59 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Discussion]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2291</guid>
		<description><![CDATA[Attention to detail is one of the most valuable things a developer can do to stand out from the crowd.]]></description>
			<content:encoded><![CDATA[<p>I consider myself a decent <acronym title="Hypertext Preprocessor">PHP</acronym> developer, and I know enough about design to ruin a beautiful image in Photoshop.  I&#8217;ve made quite a few plugins and themes over the past few years for WordPress as well.</p>
<p>When I&#8217;m asked how I got to the point I&#8217;m at in the WordPress community by upcoming developers, the best response I can give them is:  <em>It&#8217;s the little things that matter</em>.  If you&#8217;re not taking care of them, then the big, grand things you&#8217;re doing will only get you so far.</p>
<h2>What are the little things?</h2>
<p>The <em>little things</em> are usually things that WordPress does that slightly irritate me.  They don&#8217;t irritate me enough to switch platforms, but they are things that I wish were different.</p>
<p>I&#8217;ll show you an example of just what I mean with two pictures of the same comment using different themes.  See if you can find the major difference (i.e., the little thing) between the two.</p>
<p>The first is from the default WordPress theme:</p>
<p><img class="aligncenter" src="http://justintadlock.com/blog/wp-content/uploads/2010/02/default-pingback.png" alt="Default theme pingback" title="Pingback comment type from the Default WordPress theme" /></p>
<p>The second is from the development version of my <a href="http://themehybrid.com/themes/hybrid" title="Hybrid WordPress theme">Hybrid theme</a>:</p>
<p><img class="aligncenter" src="http://justintadlock.com/blog/wp-content/uploads/2010/02/hybrid-pingback.png" alt="Hybrid theme pingback" title="Pingback comment type from the Hybrid WordPress theme" /></p>
<p>Notice the difference?</p>
<p>The default theme displays the title text of the edit link for a pingback as &#8220;Edit comment,&#8221; which is standard for WordPress.  The <em>Hybrid</em> theme displays &#8220;Edit pingback&#8221; instead.</p>
<h2>Why make these little changes?</h2>
<p>At this point, you may simply think I&#8217;m crazy for changing &#8220;comment&#8221; to &#8220;pingback,&#8221; but the example is hardly the point.</p>
<p>What&#8217;s more important is that I would&#8217;ve likely had a user come along one day and ask, &#8220;How can I change &#8216;Edit comment&#8217; to &#8216;Edit pingback&#8217; for the pingback comment type?&#8221;  Rather than having to explain how to do this or even coming across the question at all, it&#8217;s already done.</p>
<p>An equally valid reason for doing so is that this is simply how I want things done on my personal blog.  And, when I code something that benefits me, it&#8217;s easy to give that back to the community.</p>
<h2>Those little things do matter</h2>
<p>While you may not take things as insanely far as I have in my example, it&#8217;s important to recognize how these seemingly insignificant things can help you and your users.  For example, this can translate into fewer support questions or become marketing points for your plugins/themes.</p>
<p>Attention to detail is the extra thing you should bring to the table, and end users always appreciate it when the details are covered.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2010/02/07/its-the-little-things-that-matter/feed</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Showing custom post types on your home/blog page</title>
		<link>http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page</link>
		<comments>http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page#comments</comments>
		<pubDate>Tue, 02 Feb 2010 08:22:47 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2283</guid>
		<description><![CDATA[How to add custom post types to your blog post rotation on your WordPress home (blog/posts) page.]]></description>
			<content:encoded><![CDATA[<p>In the last few days, I&#8217;ve shown a few people a <a href="http://justintadlock.com/blog/wp-content/uploads/2010/02/justin-tadlock-future.png" title="Justin Tadlock future home page">screenshot</a> of something I&#8217;ve been working on for this site.  The screenshot is of a home page displaying custom post types and not just the <code>post</code> post type.  After numerous requests for the code to do this, I figured it&#8217;d be much easier to share it here.</p>
<p>WordPress version 3.0 will make creating <a href="http://core.trac.wordpress.org/ticket/9674" title="WordPress Trac: Better support for custom post types">custom post types</a> extremely simple.  But, the techniques I&#8217;ll point out in this tutorial can be used with previous versions of WordPress.</p>
<h2>Changing the post type on the home page</h2>
<p>By default, WordPress shows the <code>post</code> post type on your home page.  Let&#8217;s suppose we want to show several post types in addition to posts:</p>
<ul>
<li><code>page</code> (yes, regular pages)</li>
<li><code>album</code></li>
<li><code>movie</code></li>
<li><code>quote</code></li>
</ul>
<p>To add these, open your theme&#8217;s <code>functions.php</code> file and paste this <acronym title="Hypertext Preprocessor">PHP</acronym> code into it:</p>
<pre><code>add_filter( 'pre_get_posts', 'my_get_posts' );

function my_get_posts( $query ) {

	if ( is_home() )
		$query->set( 'post_type', array( 'post', 'page', 'album', 'movie', 'quote', 'attachment' ) );

	return $query;
}</code></pre>
<p>That&#8217;s all there is to it.</p>
<p>You may have noticed the addition of the <code>attachment</code> post type even though I didn&#8217;t mention adding it.  This is something I highly recommend adding if you&#8217;ll be showing any attachment images on your home page  For example, if you have a gallery on your home page, the images won&#8217;t appear without adding the <code>attachment</code> post type.</p>
<h2>Showing the post types in your feed</h2>
<p>Realizing that many of you might want to also add these post types to your feed to match your blog, a small change in the code is required.  All you need to do is change this line:</p>
<pre><code>if ( is_home() )</code></pre>
<p>We&#8217;ll use the <code>is_feed()</code> conditional tag:</p>
<pre><code>if ( is_home() || is_feed() )</code></pre>
<p>Now, you can have custom post types in your regular blog post rotation and your feed.  Enjoy and look for more custom post type tutorials soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page/feed</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Introducing Kirby Junior</title>
		<link>http://justintadlock.com/archives/2010/01/06/introducing-kirby-junior</link>
		<comments>http://justintadlock.com/archives/2010/01/06/introducing-kirby-junior#comments</comments>
		<pubDate>Thu, 07 Jan 2010 04:40:20 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Themes]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2241</guid>
		<description><![CDATA[Should the <em>Kirby</em> theme be the new default WordPress theme?  I'm giving it a test run here on my blog, and I have a few thoughts.]]></description>
			<content:encoded><![CDATA[<div id="attachment_2242" class="wp-caption alignright" style="width: 260px"><img src="http://justintadlock.com/blog/wp-content/uploads/2010/01/kirby-junior.png" alt="Kirby Junior theme " title="Kirby Junior" width="250" height="455" class="size-full wp-image-2242" /><p class="wp-caption-text">Kirby Junior child theme</p></div>
<p>I&#8217;ve stuck with the same design for just over a year here on this blog, which is the longest I&#8217;ve ever kept a single design.  </p>
<p>And, to be honest, I haven&#8217;t been too motivated in updating it.</p>
<p>But, that all changed when I saw the first version of Ian Stewart&#8217;s <em>Kirby</em> theme posted via Twitter.</p>
<p>I liked the clean design and the large, yet elegant, typography.  It at least motivated me enough to start using the design from the <em>Kirby</em> theme here on my blog.</p>
<p>I don&#8217;t mind using other people&#8217;s designs, but it&#8217;s tough for me to use other code.  Pretty much anything I do has to run on top of the <a href="http://themehybrid.com/themes/hybrid" title="Hybrid WordPress theme"><em>Hybrid</em> theme</a>.  So, I set out to make <em>Kirby</em> a child theme of <em>Hybrid</em>.</p>
<p>I&#8217;m now using the <em>Kirby Junior</em> child theme on this site.</p>
<h2>A new default WordPress theme</h2>
<p>The point of this post isn&#8217;t to talk about how I&#8217;m using the theme on this site, but to make note that I&#8217;d love for <em>Kirby</em> to be the new default WordPress theme.  On the ThemeShaper blog, Ian has a fairly lengthy <a href="http://themeshaper.com/new-default-theme-wordpress-kirby/" title="An Idea for a New Default Theme for WordPress &mdash; Introducing Kirby">post on why it should be the default theme</a>.</p>
<p>I&#8217;ve never liked <em>Kubrick</em> (current default theme) enough to run on my blog.  <em>Kirby</em> is a theme that I&#8217;d actually use on my personal blog, which is something I don&#8217;t say often about other people&#8217;s themes.</p>
<h2>My notes on the <em>Kirby</em> theme</h2>
<p>While I am using just the design here on my blog, I did spend some time sifting through the theme code.  Overall, it&#8217;s solid.  These are some of my notes on version 0.3 of the <em>Kirby</em> theme.  Let&#8217;s hope Ian can make use of these.</p>
<ul>
<li>Integrate post images/thumbnails.  So many people use some sort of thumbnail setup these days, that it may as well be added.</li>
<li>Add a default <code>taxonomy.php</code> file to handle custom taxonomies.</li>
<li>A <code>searchform.php</code> file is needed for users that add a search form to their site.</li>
<li>I&#8217;m not a fan of the several <code>if</code>/<code>else</code> statements in the header for the <code>&lt;title></code> element. These could less-messily be done from the theme&#8217;s functions file.</li>
<li>The comment reply script should be added through <code>functions.php</code> and only active if a user is using threaded comments.</li>
<li>Users shouldn&#8217;t be required to use a custom field to turn on comments for pages.  There&#8217;s an admin option for this on the page editor screen.</li>
<li>Template code cleanup.  I&#8217;d like to see a better indentation system in place to help users understand what&#8217;s happening.</li>
</ul>
<p>These are my personal ideas for the theme.  Feel free to disagree.  And, please offer your suggestions and thoughts on the  <a href="http://themeshaper.com/new-default-theme-wordpress-kirby/" title="An Idea for a New Default Theme for WordPress &mdash; Introducing Kirby"><em>Kirby</em> theme post</a>.</p>
<p>Or, if you have alternate ideas for what the default WordPress theme should be, share your opinion.</p>
<p class="note">Please note that the design you see here on my site isn&#8217;t a completely accurate representation of the <em>Kirby</em> theme.  The version I&#8217;m using has several modifications.  I highly suggest checking out the actual theme to get a feel for how it works.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2010/01/06/introducing-kirby-junior/feed</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>My Snippets: WordPress Plugin</title>
		<link>http://justintadlock.com/archives/2009/12/03/my-snippets-wordpress-plugin</link>
		<comments>http://justintadlock.com/archives/2009/12/03/my-snippets-wordpress-plugin#comments</comments>
		<pubDate>Thu, 03 Dec 2009 17:10:49 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2225</guid>
		<description><![CDATA[The <em>My Snippets</em> plugin gives you a meta box that allows you to control widget content on a post-by-post basis.]]></description>
			<content:encoded><![CDATA[<p>One of my favorite plugins has always been <a href="http://wordpress.org/extend/plugins/widget-logic" title="Widget Logic WordPress plugin">Widget Logic</a>, which allows you to display/hide widgets based on context.  The biggest limitation of that plugin to me is that I had to go to my <em>Widgets</em> screen in my WordPress admin every time I wanted to add a new widget for a single post or page.</p>
<p>What I wanted was something that allowed me to control widget content from the post editor, so I wouldn&#8217;t have to worry about setting my widgets.  This gave me the idea for the <em>My Snippets</em> plugin.</p>
<p>What this plugin does is add an extra meta box on the post editor that allows you to input custom content.  This content is then displayed using the <em>Snippet</em> widget in any widget area you choose.</p>
<h2>How the plugin works</h2>
<p>First, you&#8217;d add the <em>Snippet</em> widget to the widget area of your choosing.  You&#8217;ll need that to display your custom snippets.</p>
<p>When writing a post (or page), you&#8217;ll have an extra meta box labeled <em>Snippet Post Settings</em>.  In this box, you can add text, <acronym title="Hypertext Markup Language">HTML</acronym>, and shortcodes.</p>
<p>Here&#8217;s an example of adding a video snippet:</p>
<p><img src="http://justintadlock.com/blog/wp-content/uploads/2009/12/snippet-settings.png" alt="Snippet post settings" title="Snippet post settings" width="600" height="217" class="aligncenter size-full wp-image-2226" /></p>
<p>Here&#8217;s the output of the snippet, which will only be displayed on the singular view of the post/page I added it to:</p>
<p><img src="http://justintadlock.com/blog/wp-content/uploads/2009/12/snippet-widget.png" alt="Output of the Snippet widget" title="Output of the Snippet widget" width="600" height="207" class="aligncenter size-full wp-image-2227" /></p>
<p>Don&#8217;t be fooled by the example though.  You can add pretty much anything in your snippet meta box, so feel free to go wild.</p>
<h2>Download the plugin</h2>
<p>Before using the plugin, please take a moment to read through the <code>readme.html</code> file included with the plugin download.</p>
<ul>
<li><strong>Version:</strong> 0.1</li>
<li><strong>Requires:</strong> WordPress 2.8+</li>
<li><strong>Support:</strong> <a href="http://themehybrid.com/support" title="Support forums at Theme Hybrid">Support forums</a></li>
<li><a href="http://wordpress.org/extend/plugins/my-snippets" title="Download the My Snippets plugin from WordPress.org">Download</a> (from WP.org)</li>
</ul>
<p class="note">Please don&#8217;t use my contact page or the comments section below to ask support questions.  Use my <a href="http://themehybrid.com/support" title="Theme Hybrid support forums">support forums</a> at Theme Hybrid, which is where I handle all support questions for my WordPress projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2009/12/03/my-snippets-wordpress-plugin/feed</wfw:commentRss>
		<slash:comments>62</slash:comments>
		</item>
		<item>
		<title>Sidebar (widget area) descriptions in WordPress 2.9</title>
		<link>http://justintadlock.com/archives/2009/11/24/sidebar-widget-area-descriptions-in-wordpress-2-9</link>
		<comments>http://justintadlock.com/archives/2009/11/24/sidebar-widget-area-descriptions-in-wordpress-2-9#comments</comments>
		<pubDate>Wed, 25 Nov 2009 02:05:41 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2216</guid>
		<description><![CDATA[How to add descriptions to individual widget areas in WordPress 2.9 and why this is a useful feature for end users.]]></description>
			<content:encoded><![CDATA[<p><span class="drop-cap">H</span>ave you ever used a WordPress theme with more than a couple of widget areas?  More specifically, have you ever used a WordPress theme with loads of widget areas and no idea how they all worked within the theme?</p>
<p>If you&#8217;ve ever used a theme of mine, you know I love adding widget areas everywhere. And, I know this can be confusing for some people.</p>
<p>Fortunately, WordPress 2.9 will allow theme developers to add a description for each widget area.  This should help end users figure out what the heck is going on.</p>
<h2>Widget descriptions from a user&#8217;s view</h2>
<p>If you&#8217;re an end user and your theme author has added descriptions, you&#8217;ll see the description near the top of the widget area on the <em>Widgets</em> admin screen.</p>
<p><img src="http://justintadlock.com/blog/wp-content/uploads/2009/11/sidebar-descriptions.png" alt="Widget Area Descriptions" title="Widget Area Descriptions" width="600" height="428" class="aligncenter size-full wp-image-2217" /></p>
<h2>Adding descriptions to widget areas</h2>
<p>If you&#8217;re a theme developer, adding descriptions to your widget areas is as simple as adding an extra argument to the <code>register_sidebar()</code> function. Use the below <acronym title="Hypertext Preprocessor">PHP</acronym> code as a guide.</p>
<pre><code>add_action( 'init', 'register_my_widget_areas' );

function register_my_widget_areas() {

	register_sidebar( array(
		'name' => __('Primary', 'example'),
		'id' => 'primary',
		'description' => __('The main widget area, most often used as a sidebar.', 'example'),
		'before_widget' => '&lt;div id="%1$s" class="widget %2$s widget-%2$s">',
		'after_widget' => '&lt;/div>',
		'before_title' => '&lt;h3 class="widget-title">',
		'after_title' => '&lt;/h3>'
	) );
}</code></pre>
<p>The new code allowed in 2.9 is the <code>description</code> argument.</p>
<pre><code>'description' => __('The main widget area, most often used as a sidebar.', 'example'),</code></pre>
<p>Theme authors, it&#8217;s time to implement this new feature for your users.  It will take less than five minutes to add to your theme and should at least cut back on a few support queries.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2009/11/24/sidebar-widget-area-descriptions-in-wordpress-2-9/feed</wfw:commentRss>
		<slash:comments>51</slash:comments>
		</item>
		<item>
		<title>Everything you need to know about WordPress 2.9&#8217;s post image feature</title>
		<link>http://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature</link>
		<comments>http://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature#comments</comments>
		<pubDate>Mon, 16 Nov 2009 07:50:08 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2126</guid>
		<description><![CDATA[An in-depth look at how the post image feature in WordPress 2.9 can be used from the perspective of both end users and developers.]]></description>
			<content:encoded><![CDATA[<p><span class="drop-cap">Y</span>ou may have heard a bit of news about a new thumbnail feature for themes coming to WordPress 2.9.  Yes, you&#8217;ll be able to easily upload a post thumbnail.  However, it&#8217;s not just thumbnails.  The image will have various sizes.  So, I&#8217;m going to refer to this feature as the post image feature.</p>
<p>In this tutorial, I&#8217;ll be covering the various things you can do with the post image feature.  Some things will be specific to end users while others will be useful for theme and plugin developers.</p>
<p>One important thing to note is that this new feature is an image-based representation of a post.  The image itself is directly tied to your post.  You shouldn&#8217;t think of it as something different than that.</p>
<h2>How does an end user make use of this feature?</h2>
<p>First, your theme must add support for it.  Otherwise, you won&#8217;t be able to use it.  At this point, let&#8217;s assume that your theme does support it.  I&#8217;ll go over instructions for theme authors later.</p>
<p>To use this feature, you must be within the post editing screen of your WordPress admin.  On this screen, you&#8217;ll see a new meta box labeled &#8220;Post thumbnail&#8221; (or &#8220;Page thumbnail&#8221; for pages).  There&#8217;ll be a link to &#8220;Set thumbnail,&#8221; which will allow you to use the media uploader to load a new image.</p>
<p><img src="http://justintadlock.com/blog/wp-content/uploads/2009/11/the-post-image.png" alt="Screenshot of WordPress 2.9's post image uploader" title="The Post Image" width="600" height="429" class="aligncenter size-full wp-image-2127" /></p>
<h2>It&#8217;s not just for thumbnails</h2>
<p>Even though it is called &#8220;post thumbnails,&#8221; we can technically use the feature for all sorts of things (e.g., feature images, medium-sized images for the front page, etc.).</p>
<p>By default, WordPress gives you several image sizes each time you upload an image.  These image sizes are:</p>
<ul>
<li>Thumbnail</li>
<li>Medium</li>
<li>Large</li>
<li>Full (the image you uploaded)</li>
</ul>
<p>Some plugins even extend this by allowing more intermediate sizes.  The important thing is that you understand that more than thumbnails can be used here.</p>
<h2>How to add support for the post image feature in a theme</h2>
<p>Theme authors, I&#8217;m going to make this simple for you.  You only need one line of code to turn this feature on for your users.  Add this to your theme&#8217;s <code>functions.php</code> file:</p>
<pre><code>add_theme_support( 'post-thumbnails' );</code></pre>
<p>Or, you can register support for specific post types.  For example, let&#8217;s suppose you wanted to add thumbnail support for both the <code>post</code> and <code>movie</code> post type but not for the <code>page</code> post type.  You&#8217;d use this instead:</p>
<pre><code>add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );</code></pre>
<p>Of course, that one line doesn&#8217;t actually add anything to the front end for you.  You&#8217;ll need to call the image somewhere within The Loop in your template files.  For example, you might want to add thumbnails to your category archives.  You&#8217;d do this by adding this line of code:</p>
<pre><code>&lt;?php the_post_thumbnail( 'thumbnail' ); ?></code></pre>
<p>Or, maybe you have a section on a special template that calls for medium-sized images:</p>
<pre><code>&lt;?php the_post_thumbnail( 'medium' ); ?></code></pre>
<p>Or, a huge sliding feature area on your front page and need the full-sized image:</p>
<pre><code>&lt;?php the_post_thumbnail( 'full' ); ?></code></pre>
<p>That&#8217;s all there is to it.  As a theme author, you can hand over some powerful functionality to your users with just a couple of lines of code.</p>
<p>The rest of this tutorial will focus on developer features and some options for using older images.</p>
<h2>Checking if the post has an image</h2>
<p>Sometimes, you may need to check if a post has an image.  There&#8217;s a function for that called <code>has_post_thumbnail()</code>, which will return <code>true</code> or <code>false</code> based on whether there&#8217;s an image.</p>
<p>In this example, we&#8217;ll check if there&#8217;s an image.  If there&#8217;s not, we&#8217;ll show a default image instead.</p>
<pre><code>&lt;?php
	if ( has_post_thumbnail() )
		the_post_thumbnail( 'thumbnail' );
	else
		echo '&lt;img src="default-image.png" alt="Example Image" title="Example" />';
?></code></pre>
<h2>Getting the post image ID</h2>
<p>Maybe you need to write your own custom script but still want to allow users to upload their own images.  You can grab the post image ID and use it.  This ID is saved as the meta value for the meta key <code>_thumbnail_id</code>.  It is the ID of the attached file.</p>
<p>You only need to call the function in your code like so:</p>
<pre><code>$image_id = get_post_thumbnail_id();</code></pre>
<h2>How to return the image instead of displaying it</h2>
<p>In some scenarios, you might want to return the post image for use in your <acronym title="Hypertext Preprocessor">PHP</acronym> code instead of displaying it.</p>
<p>Here&#8217;s an example of that functionality:</p>
<pre><code>$image = get_the_post_thumbnail( $post->ID, 'thumbnail' );</code></pre>
<h2>How to filter the image size</h2>
<p>Some plugin developers may want to filter the image size (or maybe even child theme authors).  The <code>post_thumbnail_size</code> filter hook is available for that.  The filter function below is for changing the <code>thumbnail</code> size to <code>medium</code>.</p>
<p>Add this <acronym title="Hypertext Preprocessor">PHP</acronym> code to your theme&#8217;s <code>functions.php</code> file or your plugin file:</p>
<pre><code>add_filter( 'post_thumbnail_size', 'my_post_image_size' );

function my_post_image_size( $size ) {
	$size = 'medium';
	return $size;
}</code></pre>
<h2>Changing the <acronym title="Hypertext Markup Language">HTML</acronym> output of the post image</h2>
<p>There may be some scenarios where you&#8217;ll want to change the <acronym title="Hypertext Markup Language">HTML</acronym> markup of the displayed image.  In this example, I&#8217;ll show you how to wrap the image with a link to the post.</p>
<p>Add this <acronym title="Hypertext Preprocessor">PHP</acronym> code to your theme&#8217;s <code>functions.php</code> file or your plugin file:</p>
<pre><code>add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );

function my_post_image_html( $html, $post_id, $post_image_id ) {

	$html = '&lt;a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '&lt;/a>';

	return $html;
}</code></pre>
<h2>What happens to my old images/thumbnails?</h2>
<p>If you&#8217;re like me and many others, you may have been using custom fields to add images to your posts for years.  If you switch to this new method, everything will be lost.</p>
<p>I&#8217;ve got a solution for this problem:  The <a href="http://wordpress.org/extend/plugins/get-the-image" title="Get the Image WordPress plugin">Get the Image</a> plugin.</p>
<p>Version 0.4 will be released when WordPress 2.9 is out.  Not only will support be added for the new WordPress post image feature, but you won&#8217;t lose all of the hard work you&#8217;ve put in.  The plugin will have the ability to check for post images in five different ways (in the below order):</p>
<ul>
<li>Custom fields.</li>
<li>New post image feature.</li>
<li>Attached image.</li>
<li>Scan the post for images.</li>
<li>Default image.</li>
</ul>
<p>For those of you already using this plugin or a theme of mine that includes the script, you&#8217;ll only have to upgrade the plugin or theme.  The feature will be turned on for you by default, so you will be able to start using the new feature without touching anything but an upgrade button.</p>
<h2>Have fun with your new post images</h2>
<p>I hope this tutorial has given you an in-depth look at the post image feature.  There are <a href="http://www.binarymoon.co.uk/2009/10/wordpress-the_post_image/" title="WordPress 2.9 &mdash; the_post_image">some limitations</a>, but on the whole, this feature will make things much easier for end users compared to the currently-available methods.</p>
<p>If you&#8217;re a user of my <a href="http://wordpress.org/extend/plugins/get-the-image" title="Get the Image WordPress plugin">Get the Image plugin</a> or <a href="http://themehybrid.com/themes/hybrid" title="Hybrid theme framework">Hybrid theme</a>, look out for an update within a few days of WordPress 2.9.  You&#8217;ll be able to start using the post image functionality soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature/feed</wfw:commentRss>
		<slash:comments>130</slash:comments>
		</item>
		<item>
		<title>Excerpts and taxonomies for pages in WordPress 2.9</title>
		<link>http://justintadlock.com/archives/2009/11/09/excerpts-and-taxonomies-for-pages-in-wordpress-2-9</link>
		<comments>http://justintadlock.com/archives/2009/11/09/excerpts-and-taxonomies-for-pages-in-wordpress-2-9#comments</comments>
		<pubDate>Mon, 09 Nov 2009 10:11:00 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=2122</guid>
		<description><![CDATA[How to make use of a simple file change in WordPress 2.9 to add an excerpt box and custom taxonomy boxes to your page editor.]]></description>
			<content:encoded><![CDATA[<p><span class="drop-cap">W</span>hile the information in this tutorial <em>will</em> be focused on excerpts and taxonomies, the big change in WordPress 2.9 is that the meta box functions have been included in a new file: <code>/wp-admin/include/meta-boxes.php</code>.  This change allows us to do some fun things because the code is not limited to a single area anymore.</p>
<p>In this tutorial, you&#8217;ll learn how to utilize the <code>add_meta_box()</code> functionality to add two things to your pages:</p>
<ol>
<li>Excerpt box.</li>
<li>Custom taxonomies boxes.</li>
</ol>
<p>Being able to add these meta boxes to pages isn&#8217;t the limit.  This tutorial should serve as a starting point.  You could do the same for custom post types, links, or anything that fires the <code>do_meta_boxes</code> action hook.</p>
<h2>Adding an excerpt box to your page editor</h2>
<p>The first thing you should do is open your theme&#8217;s <code>functions.php</code> file in your favorite text editor.  Paste the following <acronym title="Hypertext Preprocessor">PHP</acronym> code into it:</p>
<pre><code>add_action( 'admin_menu', 'my_page_excerpt_meta_box' );

function my_page_excerpt_meta_box() {
	add_meta_box( 'postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'page', 'normal', 'core' );
}</code></pre>
<p>Now, you&#8217;ll be able to add excerpts to your pages, just like posts.  This can come in handy with themes that display search results in excerpt form.</p>
<h2>Adding custom taxonomies to your page editor</h2>
<p>This one will be a bit trickier.  I&#8217;ll have to assume you&#8217;ve created a custom taxonomy specifically for pages.  If you&#8217;re unfamiliar with this process, you need to familiarize yourself with <a href="http://justintadlock.com/archives/2009/05/06/custom-taxonomies-in-wordpress-28" title="Custom taxonomies in WordPress 2.8">creating custom taxonomies</a>.</p>
<p>Let&#8217;s assume you&#8217;ve created a &#8220;People&#8221; taxonomy for pages.  Your custom taxonomy code should look a little like this.  </p>
<pre><code>register_taxonomy( 'people', 'page', array( 'hierarchical' => false, 'label' => 'People', 'query_var' => true, 'rewrite' => true ) );</code></pre>
<p>The important thing in that line is <code>page</code>.  We&#8217;ll be adding meta boxes for all taxonomies that have been registered for pages.</p>
<p>Again, we&#8217;ll go to our theme&#8217;s <code>functions.php</code> file.  Paste this <acronym title="Hypertext Preprocessor">PHP</acronym> code in:</p>
<pre><code>add_action( 'admin_menu', 'my_page_taxonomy_meta_boxes' );

function my_page_taxonomy_meta_boxes() {
	foreach ( get_object_taxonomies( 'page' ) as $tax_name ) {
		if ( !is_taxonomy_hierarchical( $tax_name ) ) {
			$tax = get_taxonomy( $tax_name );
			add_meta_box( "tagsdiv-{$tax_name}", $tax->label, 'post_tags_meta_box', 'page', 'side', 'core' );
		}
	}
}</code></pre>
<p>Once that&#8217;s done, you&#8217;ll be able to use your page-based custom taxonomies.</p>
<p class="note">Please note that hierarchical taxonomies aren&#8217;t going to be available yet.  Maybe in WordPress 3.0?</p>
<h2>A good move by WordPress</h2>
<p>I&#8217;m glad WordPress is moving in this direction with some of its functionality.  Average Joe might not realize the implications of something as simple as moving code to another file, but developers should rejoice.  The reuse of code is a cornerstone of good development practice.  By making things more modular, it becomes easier to create new things without rewriting a lot of code.</p>
<p>I&#8217;ve shown you how to do these things with pages.  Just imagine being able to make these simple and quick changes for custom post types (i.e., content types), essentially having the ability to create any type of site you want with WordPress.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2009/11/09/excerpts-and-taxonomies-for-pages-in-wordpress-2-9/feed</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Plugin and theme authors should force users to upgrade</title>
		<link>http://justintadlock.com/archives/2009/09/22/plugin-and-theme-authors-should-force-users-to-upgrade</link>
		<comments>http://justintadlock.com/archives/2009/09/22/plugin-and-theme-authors-should-force-users-to-upgrade#comments</comments>
		<pubDate>Wed, 23 Sep 2009 01:01:36 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Discussion]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=1829</guid>
		<description><![CDATA[By cutting off backwards compatibility, WordPress theme and plugin developers can help keep users' sites more secure.]]></description>
			<content:encoded><![CDATA[<p><span class="drop-cap">A</span> common thing we do in the WordPress community within our themes and plugins is provide backwards compatibility with older versions of WordPress.  This usually seems like a smart idea.  We want the largest possible audience, right?</p>
<p>The problem with providing backwards compatibility is twofold:</p>
<ol>
<li>Users continue using old versions of WordPress.</li>
<li>We have extra code to worry about.</li>
</ol>
<h2>Force users to upgrade</h2>
<p>With the <a href="http://lorelle.wordpress.com/2009/09/04/old-wordpress-versions-under-attack/" title="Old WordPress versions under attack">recent security scare</a> that targeted older versions of WordPress, <a href="http://weblogtoolscollection.com/archives/2009/09/12/are-you-responsible-enough-to-run-wordpress/" title="Are you responsible enough to run WordPress?">blame is being thrown around</a> left and right, from everyone to users to the WordPress developers.  While staying updated with the latest version of WordPress isn&#8217;t going to make your site 100% secure, it will make it secure from known security exploits.</p>
<p>By providing backwards compatibility in our plugins/themes, developers are partly responsible.  We&#8217;re giving users an excuse to not upgrade.  Obviously, developers are not to blame for people not upgrading their sites, but we can do our part in helping them stay secure by not supporting older versions of WordPress.</p>
<p><em>How do we not support older versions?</em>  Some things are simply going to be backwards compatible because they require no new WordPress functions, so we can&#8217;t do anything about those plugins.  The best thing to do is to use new WordPress functions as they become available and are useful to your plugin or theme.</p>
<p>Why would you want to support older versions of WordPress?  There&#8217;s no point in doing so.</p>
<h2>Get rid of code you don&#8217;t need</h2>
<p>Maybe you really don&#8217;t care if users&#8217; sites are hacked from staying on an older version.  That&#8217;s fine.  Another valid reason for keeping with the latest WordPress trends is that you don&#8217;t have to check for functions.</p>
<p>How often do you use the <code>function_exists()</code> and/or the <code>class_exists()</code> functions?</p>
<p>If you&#8217;re checking if a WordPress function exists, you&#8217;re doing so because you&#8217;re supporting older versions.  Do yourself and your users a favor and just call the function.  If it breaks a user&#8217;s site, tell them they need to upgrade.  Maybe even take a moment to explain the benefits of upgrading to them.</p>
<h2>Provide the best possible themes and plugins</h2>
<p>The WordPress developers have done about all they can do to make sure people upgrade, but we should take a bit more initiative as developers within community, the people that end users actually interact with.  By forcing users to upgrade, we&#8217;re helping them stay secure.</p>
<p>Before writing this post, I tried to think of valid reasons to provide backwards compatibility and only thought of one, and that&#8217;s the crossover period between major version upgrades.  This period should last about one month.  This gives users ample time to upgrade and provides support for people with WordPress MU.</p>
<p>I&#8217;m certainly open to other ideas about how plugin and theme developers can get more involved in the security of their users&#8217; sites.  Feel free to leave your thoughts on how they can.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2009/09/22/plugin-and-theme-authors-should-force-users-to-upgrade/feed</wfw:commentRss>
		<slash:comments>54</slash:comments>
		</item>
		<item>
		<title>Custom capabilities in plugins and themes</title>
		<link>http://justintadlock.com/archives/2009/09/18/custom-capabilities-in-plugins-and-themes</link>
		<comments>http://justintadlock.com/archives/2009/09/18/custom-capabilities-in-plugins-and-themes#comments</comments>
		<pubDate>Sat, 19 Sep 2009 02:33:50 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=1821</guid>
		<description><![CDATA[How to make your WordPress plugin or theme more flexible by allowing users to select who has access to its settings page(s).]]></description>
			<content:encoded><![CDATA[<p><span class="drop-cap">I</span> can probably list a million reasons I think my recent <a href="http://justintadlock.com/archives/2009/09/17/members-wordpress-plugin" title="Members: WordPress plugin">Members plugin</a> is neat.  Not only have I deployed it on about five of my own blogs in the last few days, I&#8217;ve also started integrating it with some of my other plugins and themes.</p>
<p>One of the features I feel that&#8217;s lacking in most plugins and themes is the ability to define custom capabilities to access certain content.  This is one of the reasons I&#8217;ve developed this plugin.</p>
<p>If you&#8217;re a plugin or theme developer and add admin menus, this tutorial should be helpful.  What I&#8217;ll be showing you is a way to give users of your plugin <em>smarter</em> control over its settings.</p>
<h2>Adding an admin menu page the normal way</h2>
<p>There are several functions for adding <a href="http://codex.wordpress.org/Adding_Administration_Menus" title="Adding administration menus">admin menus</a>, which all work basically the same way.  I&#8217;ll use <code>add_submenu_page()</code> as an example since it&#8217;s fairly common.</p>
<p>When adding a page, you&#8217;ll use the function like this:</p>
<pre><code>add_submenu_page( $parent_page, $page_title, $menu_title, $capability, $file, $function );</code></pre>
<p>What we&#8217;ll be focusing on here is the <code>$capability</code> variable.  Typically, this is hardcoded, but we need to be able to change this.  So, when writing that code, you should replace <code>$capability</code> with a filter hook:</p>
<pre><code>add_submenu_page( $parent_page, $page_title, $menu_title, apply_filters( 'plugin_name_capability', $capability ), $file, $function );</code></pre>
<p><code>plugin_name_capability</code> should be something unique to your plugin.  Just leave <code>$capability</code> as  whatever capability you would normally use.  It can now be changed.</p>
<p>Making this change does two important things:</p>
<ol>
<li>Allows users to change the capability if they want to with a filter.</li>
<li>Allows you to integrate your plugin with the <em>Members</em> plugin.</li>
</ol>
<p>You can stop reading here and will have done your part in making your plugin more flexible.  However, you can offer integration with my <em>Members</em> plugin, which will make it even easier for users to use.</p>
<h2>Integrating your plugin/theme with the Members plugin</h2>
<p>Here&#8217;s where the real neat stuff comes into play.  You can run a check to see if the <em>Members</em> plugin is installed.  If the plugin is indeed installed, you can create a custom capability just for your plugin&#8217;s settings page.</p>
<p>Let&#8217;s assume that filter hook was something like this:</p>
<pre><code>apply_filters( 'plugin_name_capability', 'manage_options' );</code></pre>
<p>People without the <em>Members</em> plugin would need the <code>manage_options</code> capability to change the settings for your plugin.  To me, that doesn&#8217;t sound like a great solution, and it definitely doesn&#8217;t offer the site owner much flexibility.</p>
<p>If the <em>Members</em> plugin is installed, we&#8217;ll change that capability to something like <code>edit_my_plugin_settings</code> (change to something unique):</p>
<pre><code>if ( function_exists( 'members_plugin_init' ) )
	add_filter( 'plugin_name_capability', 'plugin_name_unique_capability' );

function plugin_name_unique_capability( $cap ) {
	return 'edit_my_plugin_settings';
}</code></pre>
<p>Now, only users of a role with the <code>edit_my_plugin_settings</code> capability will be able to access that plugin&#8217;s page.</p>
<h2>Adding the capability to the role edit page</h2>
<p>You can offer even more integration with the <em>Members</em> plugin if you like.  You can add a checkbox to the <em>Edit Role</em> page that allows users to easily select this capability rather than typing it in.</p>
<pre><code>if ( function_exists( 'members_get_capabilities' ) )
	add_filter( 'members_get_capabilities', 'plugin_name_extra_caps' );

function plugin_name_extra_caps( $caps ) {
	$caps[] = 'edit_my_plugin_settings';
	return $caps;
}</code></pre>
<h2>Why is all this important?</h2>
<p>Imagine running a site with 20 different writers, publishers, administrators, and so on.  Some people of that site need specific access to certain things but no access to other things.</p>
<p>For example, a friend and I are both running this site with all these people.  The friend doesn&#8217;t need access to the WordPress options, but he does need access to your plugin&#8217;s options.  Those should be controlled by two separate capabilities rather than one.</p>
<p>I created <em>Members</em> to allow site owners to have as much flexibility as possible.  But, the plugin itself can only do so much on its own.  As developers in the WordPress community, we can make WordPress infinitely flexible by working together, and I&#8217;m definitely trying to make it as easy as possible to integrate other plugins with my own.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2009/09/18/custom-capabilities-in-plugins-and-themes/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Members: WordPress Plugin</title>
		<link>http://justintadlock.com/archives/2009/09/17/members-wordpress-plugin</link>
		<comments>http://justintadlock.com/archives/2009/09/17/members-wordpress-plugin#comments</comments>
		<pubDate>Thu, 17 Sep 2009 21:38:54 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>

		<guid isPermaLink="false">http://justintadlock.com/?p=1812</guid>
		<description><![CDATA[<em>Members</em> is a plugin that extends your control over your blog.  It's a user, role, and content management plugin that was created to make WordPress a more powerful <acronym title="Content Management System">CMS</acronym>.]]></description>
			<content:encoded><![CDATA[<p><span class="drop-cap">T</span>he <em>Members</em> plugin is a user, role, and content management plugin.  Its purpose is to make WordPress a more powerful <acronym title="Content Management System">CMS</acronym> by giving you fine-grain control over the users of your site.</p>
<p>I created this plugin because I wasn&#8217;t satisfied with the current user, role, and permissions plugins available.  Yes, some of them are good, but nothing fit what I had in mind perfectly.  Some offered few features.  Some worked completely outside of the WordPress role and capability system.  Others lacked an appropriate license.</p>
<p>This plugin is still a long way away from my goals, but it&#8217;ll get there eventually.</p>
<h2>What does the plugin do?</h2>
<p><em>Members</em> has what I call &#8220;components.&#8221;  Instead of normal plugin settings, you get a components-selection page that allows you to choose only the features that you want to use.  </p>
<p>The current components are (more will come in future versions):</p>
<ul>
<li><strong>Edit Roles:</strong> Edit your user roles and their capabilities.</li>
<li><strong>New Roles:</strong>  Create new roles for use on your site.</li>
<li><strong>Content Permissions:</strong>  Adds a meta box on your write post/page editor that allows you to restrict content to specific roles.</li>
<li><strong>Widgets:</strong>  Adds a login form widget and user-listing widget that you can use in any widget area on your site.</li>
<li><strong>Shortcodes:</strong>  Creates shortcodes that you can use to restrict or allow access to certain parts of your posts and pages (or any other shortcode-capable area).</li>
<li><strong>Template Tags:</strong>  New functions for use within your WordPress theme for various things.</li>
<li><strong>Private Blog:</strong>  Allows you to create a private blog that can only be accessed by users that are logged in (redirects them to the login page).</li>
</ul>
<h2>Screenshots of the plugin</h2>
<p>I&#8217;ve uploaded a few screenshots so you can see what part of the plugin looks like:</p>
<ul>
<li><a href="http://justintadlock.com/blog/wp-content/uploads/2009/09/members-components.png" title="Members select components">Select Components Screen</a></li>
<li><a href="http://justintadlock.com/blog/wp-content/uploads/2009/09/edit-roles-component.png" title="Edit Roles component">Edit Roles Component</a></li>
<li><a href="http://justintadlock.com/blog/wp-content/uploads/2009/09/new-roles-component.png" title="New Roles component">New Roles Component</a></li>
<li><a href="http://justintadlock.com/blog/wp-content/uploads/2009/09/content-permissions.png" title="Content Permissions component">Content Permissions Component</a></li>
</ul>
<h2>Ideas for future versions</h2>
<p>Version 0.1 has been all about role and capability management, but that&#8217;s just the beginning.  Version 0.2 will be about user management.</p>
<p>But, it&#8217;s not all about my ideas.  I&#8217;ll be working through many of the ideas presented in my original <a href="http://justintadlock.com/archives/2009/07/22/developing-a-user-management-plugin" title="Developing a user management plugin">post on this plugin</a>.  I&#8217;m also open to any new ideas you might have.</p>
<h2>Download the plugin</h2>
<p>Before using this plugin, please read the <code>readme.html</code> file included in the plugin download.  It will guide you through everything you need to know about using it.</p>
<ul>
<li><strong>Version:</strong> 0.1</li>
<li><strong>Requires:</strong> WordPress 2.8+</li>
<li><strong>Support:</strong> <a href="http://themehybrid.com/support" title="Support forums at Theme Hybrid">Support forums</a></li>
<li><a href="http://wordpress.org/extend/plugins/members" title="Download the Members plugin from WordPress.org">Download</a> (from WP.org)</li>
</ul>
<p class="note">Please don&#8217;t use my contact page or the comments section below to ask support questions.  Use my <a href="http://themehybrid.com/support" title="Theme Hybrid support forums">support forums</a> at Theme Hybrid, which is where I handle all support questions for my WordPress projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2009/09/17/members-wordpress-plugin/feed</wfw:commentRss>
		<slash:comments>168</slash:comments>
		</item>
	</channel>
</rss>
