<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>WordPress Theming</title>
	
	<link>http://wptheming.com</link>
	<description>Design, Customization, &amp; Consulting</description>
	<lastBuildDate>Sun, 05 Sep 2010 21:02:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/wordpress-theming" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="wordpress-theming" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">wordpress-theming</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>How to Upload Images to WordPress</title>
		<link>http://wptheming.com/2010/08/upload-images-to-wordpress/</link>
		<comments>http://wptheming.com/2010/08/upload-images-to-wordpress/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 18:22:31 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Video Tutorials]]></category>

		<guid isPermaLink="false">http://wptheming.com/?p=1041</guid>
		<description><![CDATA[This is a video tutorial showing how to upload your photos and other images into WordPress posts and pages.  It explains how to align images to the left or right, how to add a caption, and how to display multiple images in a gallery.]]></description>
			<content:encoded><![CDATA[<p>This is a video tutorial showing how to upload your photos and other images into WordPress posts and pages.  It explains how to align images to the left or right, how to add a caption, and how to display multiple images in a gallery:</p>
<p><a href="http://wptheming.com/2010/08/upload-images-to-wordpress/"><em>Click here to view the embedded video.</em></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wptheming.com/2010/08/upload-images-to-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Make an Events Custom Post Type</title>
		<link>http://wptheming.com/2010/08/how-to-make-an-events-custom-post-type/</link>
		<comments>http://wptheming.com/2010/08/how-to-make-an-events-custom-post-type/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 22:14:21 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://wptheming.com/?p=1021</guid>
		<description><![CDATA[A tutorial showing step by step instructions on how to set up a basic custom post type for events.]]></description>
			<content:encoded><![CDATA[<p><img src="http://wptheming.com/wp-content/uploads/2010/08/event-date.jpg" alt="" title="event-date" width="290" height="275" class="alignright size-full wp-image-1026" />There are several event plugins for WordPress, but all of them seem to work by adding additional tables to the database and setting up a new or complicated user interface.</p>
<p>I was working on a project with <a href="http://www.marketingfororchestras.com/">Bruce Robinson</a>, an orchestra marketer, where we wanted to just display the events using just a simple custom post type.  After stumbling down a couple wrong paths, I found a very simple and elegant solution by making the event date mirror the actual post date.</p>
<p>You can <b><a href="http://wptheming.com/downloads/events-twentyten.zip">download a child theme of Twenty Ten with all the code</a></b> that has the code I describe here.</p>
<h3>Explanation</h3>
<p>First, you&#8217;ll need to set up an event post type (and, as always, I&#8217;ll send you to <a href="http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress">Justin Tadlock&#8217;s post</a> if you want to learn more about how this works):</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1021code1'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10211"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code" id="p1021code1"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Enable Custom Post Types for Events
 */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Registers the new post type and taxonomy</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> devinsays_event_posttype<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	register_post_type<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'events'</span><span style="color: #339933;">,</span>
		<a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'labels'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Events'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'singular_name'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'add_new'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Add New Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'add_new_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Add New Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'edit_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Edit Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'new_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Add New Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'view_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'View Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'search_items'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Search Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'not_found'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'No events found'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'not_found_in_trash'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'No events found in trash'</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'public'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'supports'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'editor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thumbnail'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'comments'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'capability_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;slug&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;events&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// Permalinks format</span>
			<span style="color: #0000ff;">'menu_icon'</span> <span style="color: #339933;">=&gt;</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'stylesheet_directory'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/images/calendar-icon.gif'</span><span style="color: #339933;">,</span>  <span style="color: #666666; font-style: italic;">// Icon Path</span>
			<span style="color: #0000ff;">'menu_position'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'5'</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'devinsays_event_posttype'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Altering the &#8220;Publish Date&#8221; text</h3>
<p>We&#8217;ll need to filter the text on the event custom post type edit page.  So, instead of saying &#8220;Publish immediately&#8221; in the upper right- it&#8217;ll say &#8220;Event Date: [the current date]&#8220;.  You also need a conditional, so this text only gets filtered on your new event post type.</p>
<p>Props to Peter Westwood for <a href="http://blog.ftwr.co.uk/archives/2010/01/02/mangling-strings-for-fun-and-profit/">posting his code and explaining how to do this</a>.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1021code2'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10212"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p1021code2"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Change the &quot;Scheduled for&quot; text on Event post types changing the translation</span>
<span style="color: #666666; font-style: italic;">// http://blog.ftwr.co.uk/archives/2010/01/02/mangling-strings-for-fun-and-profit/</span>
<span style="color: #000000; font-weight: bold;">function</span> devinsays_translation_mangler<span style="color: #009900;">&#40;</span><span style="color: #000088;">$translation</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$domain</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'events'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000088;">$translations</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>get_translations_for_domain<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$domain</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Scheduled for: &lt;b&gt;%1$s&lt;/b&gt;'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$translations</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">translate</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Event Date: &lt;b&gt;%1$s&lt;/b&gt;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Published on: &lt;b&gt;%1$s&lt;/b&gt;'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$translations</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">translate</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Event Date: &lt;b&gt;%1$s&lt;/b&gt;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Publish &lt;b&gt;immediately&lt;/b&gt;'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$translations</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">translate</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Event Date: &lt;b&gt;%1$s&lt;/b&gt;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$translation</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'gettext'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'devinsays_translation_mangler'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Displaying Scheduled Posts</h3>
<p>You should now have a working post type that allows you to set up events.  However, I assume you&#8217;ll want to post events that are upcoming rather than ones that have already occurred.  Since a future date will make the event post &#8220;scheduled&#8221;, we&#8217;ll need to add a bit of code to make scheduled posts appear instead of giving a 404 error to non logged in users.  Here&#8217;s the code for that:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1021code3'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10213"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p1021code3"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Show Scheduled Posts</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> devinsays_show_scheduled_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">,</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_count</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">request</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">return</span> <span style="color: #000088;">$posts</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'devinsays_show_scheduled_posts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Displaying Events in a Template</h3>
<p>Everything should now be set up to create new events and view the posts separately.  But what if you want to query those events from different page template AND only show the events that are coming up, rather than ones that have already expired?  Well, simple.  You just query your future event posts:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1021code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10214"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p1021code4"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'events'</span><span style="color: #339933;">,</span>
							   <span style="color: #0000ff;">'posts_per_page'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'10'</span><span style="color: #339933;">,</span>
							   <span style="color: #0000ff;">'post_status'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'future'</span><span style="color: #339933;">,</span>
							   <span style="color: #0000ff;">'order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'DESC'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				query_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>You can see the full code for this in the type-events.php template in the <a href="http://wptheming.com/downloads/events-twentyten.zip">Events TwentyTen theme</a>.</p>
<h3>More with Metaboxes?</h3>
<p>I also wanted to explain the road I went down before exploring the above solution.  It involved using metaboxes to store the date- but I realized it was unworkable to do a query for the posts when there was a large amount of events (too many database queries to actually sort and display them).</p>
<p><img src="http://wptheming.com/wp-content/uploads/2010/08/end-date-metabox.jpg" alt="" title="end-date-metabox" width="290" height="221" class="alignright size-full wp-image-1027" />Even with the above caveat, it might be useful to add a date metabox if you wanted to have an end time for your event, or use a date field for some other use.</p>
<p>This section will be a bit shorter on explanation- but if you want to know more about how meta boxes work, <a href="http://wptheming.com/2010/08/custom-metabox-for-post-type">please see my other post on it</a>.</p>
<p>To add a metabox for the end date, you&#8217;ll need a callback on the event post type array:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1021code5'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10215"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1021code5"><pre class="php" style="font-family:monospace;"><span style="color: #0000ff;">'register_meta_box_cb'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'add_events_metaboxes'</span></pre></td></tr></table></div>

<h3>A Date Metabox</h3>
<p>Then you&#8217;d need to set up the actual boxes to display:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1021code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10216"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
</pre></td><td class="code" id="p1021code6"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Add the Events Meta Boxes</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> add_events_metaboxes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	add_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'devinsays_events_date'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'End Date'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'devinsays_events_date'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'events'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'side'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'default'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// The Event Date Metabox</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> devinsays_events_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">,</span> <span style="color: #000088;">$wp_locale</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Use nonce for verification ... ONLY USE ONCE!</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input type=&quot;hidden&quot; name=&quot;eventmeta_noncename&quot; id=&quot;eventmeta_noncename&quot; value=&quot;'</span> <span style="color: #339933;">.</span> 
	wp_create_nonce<span style="color: #009900;">&#40;</span> plugin_basename<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$time_adj</span> <span style="color: #339933;">=</span> current_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'timestamp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$month</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_month'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$month</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$month</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/gmdate"><span style="color: #990000;">gmdate</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'m'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time_adj</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$day</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_day'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$day</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$day</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/gmdate"><span style="color: #990000;">gmdate</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'d'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time_adj</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$year</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_year'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$year</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$year</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/gmdate"><span style="color: #990000;">gmdate</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Y'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time_adj</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$hour</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_hour'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hour</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$hour</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/gmdate"><span style="color: #990000;">gmdate</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'H'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time_adj</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$min</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_minute'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$min</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$min</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'00'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$month_s</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;select name=<span style="color: #000099; font-weight: bold;">\&quot;</span>_month<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">13</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$month_s</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;option value=&quot;'</span> <span style="color: #339933;">.</span> zeroise<span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$month</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$month_s</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$month_s</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$wp_locale</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_month_abbrev</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$wp_locale</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_month</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/option&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$month_s</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;/select&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$month_s</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input type=&quot;text&quot; name=&quot;_day&quot; value=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$day</span>  <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; size=&quot;2&quot; maxlength=&quot;2&quot; /&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input type=&quot;text&quot; name=&quot;_year&quot; value=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$year</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; size=&quot;4&quot; maxlength=&quot;4&quot; /&gt; @ '</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input type=&quot;text&quot; name=&quot;_hour&quot; value=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$hour</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; size=&quot;2&quot; maxlength=&quot;2&quot;/&gt;:'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input type=&quot;text&quot; name=&quot;_minute&quot; value=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$min</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; size=&quot;2&quot; maxlength=&quot;2&quot; /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h3>Saving the Meta Data</h3>
<p>You&#8217;d also want to save the all that information:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1021code7'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10217"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code" id="p1021code7"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Save the Metabox Data</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> devinsays_save_events_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// verify this came from the our screen and with proper authorization,</span>
	<span style="color: #666666; font-style: italic;">// because save_post can be triggered at other times</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>wp_verify_nonce<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'eventmeta_noncename'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> plugin_basename<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Is the user allowed to edit the post or page?</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'edit_post'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// OK, we're authenticated: we need to find and save the data</span>
	<span style="color: #666666; font-style: italic;">// We'll put it into an array to make it easier to loop though.</span>
&nbsp;
	<span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_month'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_month'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_day'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_day'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_year'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_year'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_hour'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_hour'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_minute'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_minute'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_eventtimestamp'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_year'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_month'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_day'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_hour'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_minute'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Add values of $events_meta as custom fields</span>
&nbsp;
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$events_meta</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// Cycle through the $events_meta array!</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'revision'</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Don't store custom data twice</span>
		<span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#41;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// If $value is an array, make it a CSV (unlikely)</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// If the custom field already has a value</span>
			update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// If the custom field doesn't have a value</span>
			add_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> delete_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Delete if blank</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'save_post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'devinsays_save_events_meta'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// save the custom fields</span></pre></td></tr></table></div>

<h3>Code for Displaying the Date in a Easy Format</h3>
<p>And perhaps add a bit of code that will allow you to display the end date easily on the page:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1021code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10218"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code" id="p1021code8"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Get the Month Abbreviation</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> devinsays_get_the_month_abbr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$month</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_locale</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">13</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$month</span> <span style="color: #009900;">&#41;</span>
					<span style="color: #000088;">$monthabbr</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_locale</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_month_abbrev</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$wp_locale</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_month</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$monthabbr</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Get the Month Abbreviation</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> devinsays_get_the_event_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$eventdate</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$month</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_month'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$eventdate</span> <span style="color: #339933;">=</span> devinsays_get_the_month_abbr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$month</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$eventdate</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' '</span> <span style="color: #339933;">.</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_day'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">','</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$eventdate</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' '</span> <span style="color: #339933;">.</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_year'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$eventdate</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' at '</span> <span style="color: #339933;">.</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_hour'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$eventdate</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">':'</span> <span style="color: #339933;">.</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_minute'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$eventdate</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h3>Query Issues</h3>
<p>I had originally planned to use the metaboxes to store the event date, rather than using the publish date, but moved to the other route when I realized I&#8217;d need another query variable in order to display the posts.  But, if you didn&#8217;t have many and weren&#8217;t worried about a huge amount of database queries, you could always do something like this to display the posts by the meta data:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p1021code9'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10219"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
</pre></td><td class="code" id="p1021code9"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
				<span style="color: #000088;">$time_adj</span> <span style="color: #339933;">=</span> current_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'timestamp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$current_time</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/gmdate"><span style="color: #990000;">gmdate</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Y m d H i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time_adj</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$current_time</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$current_time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
				<span style="color: #000000; font-weight: bold;">&lt;?php</span>           
				<span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'events'</span><span style="color: #339933;">,</span>
							   <span style="color: #0000ff;">'meta_key'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'_eventtimestamp'</span><span style="color: #339933;">,</span>
							   <span style="color: #0000ff;">'orderby'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'meta_value'</span><span style="color: #339933;">,</span>
							   <span style="color: #0000ff;">'posts_per_page'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'-1'</span><span style="color: #339933;">,</span>
							   <span style="color: #0000ff;">'order'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ASC'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				query_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
				<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
            <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$event_timestamp</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;_eventtimestamp&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
            <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$event_timestamp</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$current_time</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
            <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post-&lt;?php the_ID(); ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&gt;</span>
			<span style="color: #339933;">&lt;</span>h2 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-title&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php printf( esc_attr__( 'Permalink to <span style="color: #009933; font-weight: bold;">%s</span>', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?&gt;&quot;</span> rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;bookmark&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>h2<span style="color: #339933;">&gt;</span>
&nbsp;
			<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-meta&quot;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-prep&quot;</span><span style="color: #339933;">&gt;&lt;</span>b<span style="color: #339933;">&gt;</span>Event <a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #339933;">:&lt;/</span>b<span style="color: #339933;">&gt;&lt;/</span>span<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-date&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php devinsays_get_the_event_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
			<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>meta <span style="color: #339933;">--&gt;</span>
&nbsp;
            <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-summary&quot;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
			<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>summary <span style="color: #339933;">--&gt;</span>
		<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#post-## --&gt;
</span>        
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>What do you think?</h3>
<p>I know a lot of people are working on ways to do events well.  Ideally a terrific plugin will come along that makes this all very easy.  I just wanted to spur the process.  If anyone has any comments or improvement for the code, please let me know.</p>
<p>And again, my sample <b><a href="http://wptheming.com/downloads/events-twentyten.zip">Events TwentyTen theme can be downloaded here</a></b>.</p>
]]></content:encoded>
			<wfw:commentRss>http://wptheming.com/2010/08/how-to-make-an-events-custom-post-type/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How to Add a Metabox to a Custom Post Type</title>
		<link>http://wptheming.com/2010/08/custom-metabox-for-post-type/</link>
		<comments>http://wptheming.com/2010/08/custom-metabox-for-post-type/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 22:50:27 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Custom Post Types]]></category>

		<guid isPermaLink="false">http://wptheming.com/?p=989</guid>
		<description><![CDATA[A tutorial explaining how to build custom meta boxes to be used with different post types.]]></description>
			<content:encoded><![CDATA[<p><a href="http://wptheming.com/wp-content/uploads/2010/08/metabox1.png"><img src="http://wptheming.com/wp-content/uploads/2010/08/metabox1.png" alt="" title="metabox1" width="290" height="213" class="alignright size-full wp-image-998" /></a>Most custom post types in WordPress will need (or could benefit from) a unique set metaboxes for entering information.</p>
<p>For example, a &#8220;photography&#8221; post type might need fields for &#8220;location of photo&#8221;, &#8220;type of camera&#8221;, etc.  And an &#8220;event&#8221; post type would probably need a &#8220;location&#8221; and an &#8220;event date&#8221;.</p>
<p>Metaboxes aren&#8217;t the easiest to set up- so I&#8217;ve written up this tutorial which shows how to add a one line field for &#8220;location&#8221; to an &#8220;event&#8221; post type.</p>
<p>Hopefully, you&#8217;ll be able to use this guide to add any sort of metaboxes you need.</p>
<h3>Set Up the Post Type</h3>
<p>If you are unfamiliar with how to set up custom post types, check out <a href="http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress">Justin Tadlock&#8217;s excellent tutorial</a>.  For this example, I am going to use a post type called &#8220;Event&#8221;, which goes in my functions.php file:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p989code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p98910"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code" id="p989code10"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Registers the new post type and taxonomy</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> wpt_event_posttype<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	register_post_type<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'events'</span><span style="color: #339933;">,</span>
		<a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'labels'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Events'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'singular_name'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'add_new'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Add New Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'add_new_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Add New Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'edit_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Edit Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'new_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Add New Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'view_item'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'View Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'search_items'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Search Event'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'not_found'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'No events found'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">'not_found_in_trash'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'No events found in trash'</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'public'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'supports'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'editor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thumbnail'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'comments'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'capability_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;slug&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;events&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// Permalinks format</span>
			<span style="color: #0000ff;">'menu_position'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'register_meta_box_cb'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'add_events_metaboxes'</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpt_event_posttype'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>You may have your own custom post type set up completely different, but that&#8217;s fine.  The important line of code for the metaboxes is &#8216;register_meta_box_cb&#8217; => &#8216;add_events_metaboxes&#8217;- which calls the function to build the metaboxes.</p>
<p>You can rename the function to whatever you like, for instance &#8216;register_meta_box_cb&#8217; => &#8216;add_photography_metaboxes&#8217; might be better for a photography post type.</p>
<h3>Add Meta Box</h3>
<p>The following code adds a metabox to the right side of the screen under the &#8220;Publish&#8221; box:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p989code11'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p98911"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p989code11"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Add the Events Meta Boxes</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> add_events_metaboxes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	add_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wpt_events_location'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Event Location'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpt_events_location'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'events'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'side'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'default'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>You can read the full parameters for <a href="http://codex.wordpress.org/Function_Reference/add_meta_box">add_meta_box in the codex</a>.  I also listed them here:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p989code12'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p98912"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p989code12"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> add_meta_box<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$title</span><span style="color: #339933;">,</span> <span style="color: #000088;">$callback</span><span style="color: #339933;">,</span> <span style="color: #000088;">$page</span><span style="color: #339933;">,</span> <span style="color: #000088;">$context</span><span style="color: #339933;">,</span> <span style="color: #000088;">$priority</span><span style="color: #339933;">,</span> <span style="color: #000088;">$callback_args</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>For the example above:</p>
<ul>
<li>$id is &#8220;wpt_events_location&#8221;- or the html id that will be applied to this metabox.</li>
<li>$title is &#8220;Event Location&#8221;.  This appears at the top of the new metabox when displayed.</li>
<li>$callback is the function &#8220;wpt_events_location&#8221; which will load the html into the metabox.</li>
<li>$page is &#8220;events&#8221;, the name of our custom post type.</li>
<li>$context is &#8220;side&#8221;.  If you wanted it to load below the content area, you could put &#8220;normal&#8221;.</li>
<li>$priority controls where the metabox will display in relation to the other metaboxes.  You can put &#8220;high&#8221;, &#8220;low&#8221; or &#8220;default&#8221;.</li>
</ul>
<p>If you wanted to have two sets of metaboxes, perhaps one on the side and one below the content area, you could do something like this (Note: Don&#8217;t use this if you&#8217;re following the tutorial step by step, this is just an example of how it would be done):</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p989code13'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p98913"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p989code13"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Add the Events Meta Boxes</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> add_events_metaboxes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	add_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wpt_events_date'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Event Date'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpt_events_date'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'events'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'side'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'default'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	add_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wpt_events_location'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Event Location'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpt_events_location'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'events'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'normal'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'high'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>You&#8217;d then have to make sure the two function wpt_events_date and wpt_events_location were defined to call the html code to go inside the metaboxes.</p>
<h3>Generating the HTML for the Metabox</h3>
<p>Continuing with the first example above, we&#8217;ll now have to generate the code that goes inside our &#8220;Event Location&#8221; metabox.  To keep this as simple as possible, we&#8217;re just going to make one field:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p989code14'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p98914"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p989code14"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// The Event Location Metabox</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> wpt_events_location<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Noncename needed to verify where the data originated</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input type=&quot;hidden&quot; name=&quot;eventmeta_noncename&quot; id=&quot;eventmeta_noncename&quot; value=&quot;'</span> <span style="color: #339933;">.</span> 
	wp_create_nonce<span style="color: #009900;">&#40;</span> plugin_basename<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Get the location data if its already been entered</span>
	<span style="color: #000088;">$location</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_location'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Echo out the field</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input type=&quot;text&quot; name=&quot;_location&quot; value=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$location</span>  <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; class=&quot;widefat&quot; /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>At this point you should have a metabox showing up in your post.  If you check your &#8220;events&#8221; post type, it should load on the right side like in the screenshot I posted.  This will generate any html you choose, so, you could put as many input fields in here as you like, or html descriptions.</p>
<p>In order to class the inputs and descriptions correctly, check out the source code for other write panels in WordPress.  See how they do textareas and select boxes.  You can even add icons and generated text in these spots.</p>
<h3>Saving</h3>
<p>If you had tried to save your metabox data before this point, it just would have disappeared on the refresh because it wasn&#8217;t being saved.  Here&#8217;s the code that updates the metabox when you click &#8220;Update&#8221; (adapted from <a href="http://www.nathanrice.net">Nathan Rice</a> in the AgentPress theme):</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p989code15'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p98915"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code" id="p989code15"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Save the Metabox Data</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> wpt_save_events_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// verify this came from the our screen and with proper authorization,</span>
	<span style="color: #666666; font-style: italic;">// because save_post can be triggered at other times</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>wp_verify_nonce<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'eventmeta_noncename'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> plugin_basename<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Is the user allowed to edit the post or page?</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>current_user_can<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'edit_post'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// OK, we're authenticated: we need to find and save the data</span>
	<span style="color: #666666; font-style: italic;">// We'll put it into an array to make it easier to loop though.</span>
&nbsp;
	<span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_location'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_location'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Add values of $events_meta as custom fields</span>
&nbsp;
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$events_meta</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// Cycle through the $events_meta array!</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'revision'</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Don't store custom data twice</span>
		<span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#41;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// If $value is an array, make it a CSV (unlikely)</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// If the custom field already has a value</span>
			update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// If the custom field doesn't have a value</span>
			add_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> delete_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Delete if blank</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'save_post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpt_save_events_meta'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// save the custom fields</span></pre></td></tr></table></div>

<p>This code checks to make sure the user has privileges to update the post, then saves all the input data into the array $events_meta.</p>
<h3>An Additional Example</h3>
<p><img src="http://wptheming.com/wp-content/uploads/2010/08/metabox2.jpg" alt="" title="metabox2" width="290" height="160" class="alignright size-full wp-image-999" />If we wanted to have additional fields, we&#8217;d need to output them in the metabox callback (in this case: wpt_events_location) and make sure they&#8217;re saved in the by adding them to the array in wpt_save_events_meta.</p>
<p>This is how you would add an additional field for &#8220;dress code&#8221;.  First, update the function wpt_events_location to:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p989code16'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p98916"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p989code16"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// The Event Location Metabox</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> wpt_events_location<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Noncename needed to verify where the data originated</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input type=&quot;hidden&quot; name=&quot;eventmeta_noncename&quot; id=&quot;eventmeta_noncename&quot; value=&quot;'</span> <span style="color: #339933;">.</span> 
	wp_create_nonce<span style="color: #009900;">&#40;</span> plugin_basename<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Get the location data if its already been entered</span>
	<span style="color: #000088;">$location</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_location'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$dresscode</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_dresscode'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Echo out the field</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;Enter the location:&lt;/p&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input type=&quot;text&quot; name=&quot;_location&quot; value=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$location</span>  <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; class=&quot;widefat&quot; /&gt;'</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;How Should People Dress?&lt;/p&gt;'</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input type=&quot;text&quot; name=&quot;_dresscode&quot; value=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$dresscode</span>  <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; class=&quot;widefat&quot; /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now add the extra array item to wpt_save_events_meta- so it looks like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p989code17'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p98917"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p989code17"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_location'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_location'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$events_meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_dresscode'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'_dresscode'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Displaying the Metabox Information in a Template</h3>
<p>To display the metabox information in your page templates, you&#8217;ll need to fetch the metabox data stored in the post.  If you&#8217;re inside the loop, you would do it like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p989code18'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p98918"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p989code18"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;_location&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>More information about this is available in the codex: <a href="http://codex.wordpress.org/Function_Reference/get_post_meta">http://codex.wordpress.org/Function_Reference/get_post_meta</a></p>
<h3>Other Tutorials</h3>
<p>There&#8217;s a few other tutorials on the web that have been extremely helpful for figuring this stuff out.  One of the best is: <a href="http://www.deluxeblogtips.com/2010/04/how-to-create-meta-box-wordpress-post.html">How to Create a Better Meta Box in WordPress</a>.</p>
<p>Please share the code and enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://wptheming.com/2010/08/custom-metabox-for-post-type/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Adding Columns to the WP Edit Pages</title>
		<link>http://wptheming.com/2010/07/column-edit-pages/</link>
		<comments>http://wptheming.com/2010/07/column-edit-pages/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 22:47:51 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Custom Post Types]]></category>

		<guid isPermaLink="false">http://wptheming.com/?p=971</guid>
		<description><![CDATA[A couple weeks ago I released a Portfolio Theme that uses custom post types.  The featured image is a key component of the post type, I wanted a way to display it from the post dashboard- along with the title, taxonomy, author, comments, and post date.]]></description>
			<content:encoded><![CDATA[<p>A couple weeks ago I released the <a href="http://wptheming.com/2010/07/portfolio-theme/">Portfolio Theme</a>, which uses custom post types to display images and portfolio information.  Since the featured image is a key component of the post type, I wanted a way to display that from the post dashboard- along with the title, taxonomy, author, comments, and post date.</p>
<p><img src="http://wptheming.com/wp-content/uploads/2010/07/portfolio-edit-page-590x349.png" alt="" title="portfolio-edit-page" width="590" height="349" class="alignright size-large wp-image-972" /></p>
<p>I couldn&#8217;t find any code snippets available that did exactly what I wanted, but I did get close with WP Engineer&#8217;s <a href="http://wpengineer.com/display-post-thumbnail-post-page-overview/">post about adding thumbnails to post and pages</a> and Shiba&#8217;s post <a href="http://shibashake.com/wordpress-theme/add-custom-post-type-columns">about adding custom post type columns</a>.</p>
<p>You&#8217;re welcome to <a href="http://wptheming.com/2010/07/portfolio-theme/">download the Portfolio Theme</a> and see how all the code was included.  The code below is just the specific part about adding columns to edit screen.</p>
<p>Note, I already have a custom post type &#8220;portfolio&#8221; built.  If you wanted to use these columns with a &#8220;art&#8221; post type for instance, you would need to swap out the name.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p971code19'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p97119"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
</pre></td><td class="code" id="p971code19"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//  Add Columns to Portfolio Edit Screen</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;manage_edit-portfolio_columns&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;portfolio_edit_columns&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;manage_posts_custom_column&quot;</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">&quot;portfolio_columns_display&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post-thumbnails'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'portfolio'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> portfolio_edit_columns<span style="color: #009900;">&#40;</span><span style="color: #000088;">$portfolio_columns</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$portfolio_columns</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">&quot;cb&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;&lt;input type=<span style="color: #000099; font-weight: bold;">\&quot;</span>checkbox<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;title&quot;</span> <span style="color: #339933;">=&gt;</span> _x<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Title'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'column name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;thumbnail&quot;</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Thumbnail'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;portfolio-tags&quot;</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tags'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;author&quot;</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Author'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;comments&quot;</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;date&quot;</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Date'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$portfolio_columns</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'comments'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;div class=&quot;vers&quot;&gt;&lt;img alt=&quot;Comments&quot; src=&quot;'</span> <span style="color: #339933;">.</span> esc_url<span style="color: #009900;">&#40;</span> admin_url<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'images/comment-grey-bubble.png'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; /&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$portfolio_columns</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> portfolio_columns_display<span style="color: #009900;">&#40;</span><span style="color: #000088;">$portfolio_columns</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$portfolio_columns</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Code from: http://wpengineer.com/display-post-thumbnail-post-page-overview</span>
&nbsp;
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;thumbnail&quot;</span><span style="color: #339933;">:</span>
			<span style="color: #000088;">$width</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #cc66cc;">35</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$height</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #cc66cc;">35</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$thumbnail_id</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post_id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_thumbnail_id'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #666666; font-style: italic;">// image from gallery</span>
				<span style="color: #000088;">$attachments</span> <span style="color: #339933;">=</span> get_children<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_parent'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$post_id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'attachment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_mime_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'image'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumbnail_id</span><span style="color: #009900;">&#41;</span>
					<span style="color: #000088;">$thumb</span> <span style="color: #339933;">=</span> wp_get_attachment_image<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$thumbnail_id</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachments</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$attachments</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$attachment_id</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$attachment</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #000088;">$thumb</span> <span style="color: #339933;">=</span> wp_get_attachment_image<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$attachment_id</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
					<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$thumb</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$thumb</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$thumb</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #b1b100;">echo</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'None'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>	
		<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;portfolio-tags&quot;</span><span style="color: #339933;">:</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tag_list</span> <span style="color: #339933;">=</span> get_the_term_list<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'portfolio-tags'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">', '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$tag_list</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">echo</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'None'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>			
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://wptheming.com/2010/07/column-edit-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Browser Body Classes in WordPress</title>
		<link>http://wptheming.com/2010/07/browser-body-classes/</link>
		<comments>http://wptheming.com/2010/07/browser-body-classes/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 17:48:55 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[WordPress Tips]]></category>

		<guid isPermaLink="false">http://wptheming.com/?p=947</guid>
		<description><![CDATA[You should be able to add this code to any WordPress site.  It extends the default body classes to include browser detection.  So, if you want to add a specific style for IE6, you can just class it like .ie6 #mydiv { }.  I think it's much more elegant than pulling up multiple stylesheets for all the different browsers.]]></description>
			<content:encoded><![CDATA[<p>You should be able to add this code to any WordPress site.  It extends the default body classes to include browser detection.  So, if you want to add a specific style for IE6, you can just class it like .ie6 #mydiv { }.  I think it&#8217;s more elegant than pulling up multiple stylesheets for all the different browsers.</p>
<p>If the code doen&#8217;t work right off the bat, make sure your theme uses the body_class() function.  Your body tag should look something like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p947code20'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p94720"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p947code20"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>body <span style="color: #000000; font-weight: bold;">&lt;?php</span> body_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><br/></p>
<h3>Browser Body Classes Code</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p947code21'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p94721"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
</pre></td><td class="code" id="p947code21"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Extends the body_class(); to include browser detection
 * Props to Thematic: http://wordpress.org/extend/themes/thematic
 */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> browser_body_class<span style="color: #009900;">&#40;</span><span style="color: #000088;">$classes</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// A little Browser detection shall we?</span>
	<span style="color: #000088;">$browser</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span> <span style="color: #0000ff;">'HTTP_USER_AGENT'</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Mac, PC ...or Linux</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/Mac/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'mac'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/Windows/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'windows'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/Linux/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'linux'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'unknown-os'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Checks browsers in this order: Chrome, Safari, Opera, MSIE, FF</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/Chrome/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'chrome'</span><span style="color: #339933;">;</span>
&nbsp;
		<a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/Chrome\/(\d.\d)/si&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$classesh_version</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ch'</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      
		<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$classesh_version</span><span style="color: #339933;">;</span>
&nbsp;
	    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/Safari/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'safari'</span><span style="color: #339933;">;</span>
&nbsp;
			<a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/Version\/(\d.\d)/si&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$sf_version</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'sf'</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      
			<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$sf_version</span><span style="color: #339933;">;</span>
&nbsp;
	     <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/Opera/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'opera'</span><span style="color: #339933;">;</span>
&nbsp;
			<a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/Opera\/(\d.\d)/si&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$op_version</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'op'</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      
			<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$op_version</span><span style="color: #339933;">;</span>
&nbsp;
	     <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/MSIE/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'msie'</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/MSIE 6.0/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ie6'</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/MSIE 7.0/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ie7'</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/MSIE 8.0/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ie8'</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/MSIE 9.0/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ie9'</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
	        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/Firefox/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/Gecko/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'firefox'</span><span style="color: #339933;">;</span>
&nbsp;
				<a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/Firefox\/(\d)/si&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$ff_version</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ff'</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      
				<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ff_version</span><span style="color: #339933;">;</span>
&nbsp;
	        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'unknown-browser'</span><span style="color: #339933;">;</span>
	        <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$classes</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'body_class'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'browser_body_class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>I&#8217;ve been trying to add mobile detection as well, but haven&#8217;t yet had any luck.  Any ideas why the following wouldn&#8217;t work?</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p947code22'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p94722"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p947code22"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/preg_match"><span style="color: #990000;">preg_match</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/iPhone/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$browser</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'iPhone'</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://wptheming.com/2010/07/browser-body-classes/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to Edit the Text of Any Website</title>
		<link>http://wptheming.com/2010/07/edit-the-text-of-any-website/</link>
		<comments>http://wptheming.com/2010/07/edit-the-text-of-any-website/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 05:16:31 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://wptheming.com/?p=940</guid>
		<description><![CDATA[If you type the following javascript code snippet into your navigation bar, you should be able to edit any text on the page.  Also includes video demonstration.]]></description>
			<content:encoded><![CDATA[<p>If you type the following javascript code snippet into your navigation bar, you should be able to edit any text on the page:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p940code23'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p94023"><td class="code" id="p940code23"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span>document.<span style="color: #660066;">body</span>.<span style="color: #660066;">contentEditable</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'true'</span><span style="color: #339933;">;</span> document.<span style="color: #660066;">designMode</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'on'</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">void</span> <span style="color: #CC0000;">0</span></pre></td></tr></table></div>

<h3>Video Demo</h3>
<p><a href="http://wptheming.com/2010/07/edit-the-text-of-any-website/"><em>Click here to view the embedded video.</em></a></p>
<p>I learned this neat little trick from Matt Thompson at the last <a href="http://www.refreshaustin.org/2010/refresh-july-tool-roundup/">Refresh Austin</a>.  </p>
]]></content:encoded>
			<wfw:commentRss>http://wptheming.com/2010/07/edit-the-text-of-any-website/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Portfolio Theme</title>
		<link>http://wptheming.com/2010/07/portfolio-theme/</link>
		<comments>http://wptheming.com/2010/07/portfolio-theme/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 04:57:43 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://wptheming.com/?p=926</guid>
		<description><![CDATA[I'm proud to announce a new html5 portfolio theme.  It uses custom post types for <b><a href="http://themequery.com/portfolio/">portfolio pages</a></b>, takes advantage of the new menu navigation, and includes a ton of neat features.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m proud to announce a new html5 portfolio theme.  It uses custom post types for <b><a href="http://themequery.com/portfolio/">portfolio pages</a></b>, takes advantage of the new menu navigation, and includes a ton of neat features.  Here&#8217;s a video screencast of how it works:</p>
<p><a href="http://wptheming.com/2010/07/portfolio-theme/"><em>Click here to view the embedded video.</em></a></p>
<h3><a href="http://wordpress.org/extend/themes/download/portfolio-theme.0.4.2.zip">Download It</a> | <a href="http://themequery.com">Demo It</a></h3>
<p>The theme just got included in the <a href="http://wordpress.org/extend/themes/portfolio-theme">WordPress Themes Directory</a>.  You can <b><a href="http://themequery.com">demo it here</a></b>.  Or <b><a href="http://wordpress.org/extend/themes/download/portfolio-theme.0.4.2.zip">download a copy</a></b> and try it out.</p>
<h3>Examples of the Portfolio Theme in Action</h3>
<p><a href="http://www.bergting.com/">Peter Bergting &#8211; Comic Book Artist and Writer</a></p>
<h3>What&#8217;s New in Version 0.4</h3>
<ul>
<li>Changed title filter priority in simple-custom-post-type-archives.php</li>
<li>Added better handling for the Simple Custom Post Type Archives plugin</li>
<li>Updated the menu_postion for the portfolio post type</li>
<li>Combined the portfolio post type and custom taxonomy into the same init hook</li>
<li>Added better labels to the portfolio post type</li>
<li>Updated the hover states on the menu to use stop(true)</li>
<li>Added thumbnails and taxonomy tags to the column view for portfolio post type</li>
<li>Added an icon to the portfolio post type</li>
</ul>
<h3>Credits</h3>
<p>Portfolio was built on the solid foundation of Toolbox:<br />
<a href="http://wordpress.org/extend/themes/toolbox">http://wordpress.org/extend/themes/toolbox</a></p>
<p>Styles, especially the menus and buttons, were inspired by Canvas:<br />
<a href="http://www.woothemes.com/2010/02/canvas/">http://www.woothemes.com/2010/02/canvas/</a></p>
<p>Jquery rollovers for portfolio items was based on code by:<br />
<a href="http://graphpaperpress.com/themes/workspace/">http://graphpaperpress.com/themes/workspace/</a></p>
<p>Uses Custom Post Type Archives plugin to enable portfolio paging and permalinks:<br />
<a href="http://www.cmurrayconsulting.com/software/wordpress-custom-post-type-archives/">http://www.cmurrayconsulting.com/software/wordpress-custom-post-type-archives/</a></p>
<h3>Special Thanks</h3>
<p>Also, special thanks to Michael Fields and Jake M Gold who helped test the theme and gave excellent feedback + code suggestions.</p>
<h3>Instructions and Common Questions</h3>
<p><b>How to Set Up a Portfolio Item:</b></p>
<p>When you activate the Portfolio Theme, you will see a new post type called &#8220;Portfolio&#8221;.  Click &#8220;Add New Item&#8221; and you will be taken to the edit page where you can add a title, description, and tags for your portfolio piece.</p>
<p>To add the portfolio image, click &#8220;Set featured image&#8221; on the right side of the screen beneath &#8220;Portfolio Tags&#8221;.  This will take you to the media uploader to add your image.  When you finish, click &#8220;Use as Featured Image&#8221;.</p>
<p><b>404 Errors:</b></p>
<p>This theme uses custom post types.  If you are getting a 404 error when you try and view the portfolio posts, reset your permalinks.  You can do this by going to &#8220;Settings > Permalinks&#8221; and re-saving the permalink structure.</p>
<p><b>Portfolio Items Disappear:</b></p>
<p>If you change themes, chances are your portfolio pieces will disappear from the dashboard.  Fear not!  They are still saved in the database- your new theme just wasn&#8217;t programmed to list and display them.</p>
<p>If you are handy with code, you can just copy the two extensions &#8220;portfolio-post-type.php&#8221; and &#8220;simple-custom-post-type-archives.php&#8221; into your new theme and call them from the functions.php file.  You&#8217;ll also have to build new template files to display the custom post types in your theme.  If coding isn&#8217;t your thing, you could hire a WordPress developer to help you out with the project.</p>
<p><b>How do I change the size of the thumbnail images?</b></p>
<p>At some point I will probably make theme options for this, but for now you&#8217;ll have to do this through the code.  Open the file portfolio-post-type.php in the &#8220;extensions&#8221; folder, and fine the line of code that says: add_image_size( &#8216;portfolio-thumbnail&#8217;, 215, 175, true );.  The first number &#8220;215&#8243; is the width- the second number &#8220;175&#8243; is the height.  Note, that there is a clear div generated every 3 items to start the next row- so if you change this to only have two items across, you&#8217;ll also need to update that code in type-portfolio.php.</p>
<p><b>Can I stop the featured image showing in double in the portfolio?</b></p>
<p>The featured image should not show up twice in the single post view.  Make sure that you didn&#8217;t accidentally insert the image into the post (it pulls automatically).  If you want to manually insert the images and put whatever content you want into the post- delete these lines from single-portfolio.php:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p926code24'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p92624"><td class="line_numbers"><pre>34
35
36
</pre></td><td class="code" id="p926code24"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>has_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'large'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><b>Can I display my portfolio items in with my regular posts?</b></p>
<p>Yes, but you&#8217;ll just need to update the query call on every template where you want both to appear.  See Justin Tadlock&#8217;s article <a href="http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page">about this</a>.  The intention of this theme was to have them live separately.</p>
<p><b>Can I change the permalink slug from &#8220;portfolio&#8221; to a name of my own choosing?</b></p>
<p>If you know a little about how custom post types work it shouldn&#8217;t be that difficult.  You&#8217;d need to change the registered post type from &#8220;portfolio&#8221; to something like &#8220;art&#8221; (for example), and update the labels and queries.  Perhaps in a later version of the theme I&#8217;ll make an option for this, but for now you&#8217;ll have to dig through the code a bit or <a href="http://wptheming.com/contact">hire someone</a> to make the needed changes.</p>
]]></content:encoded>
			<wfw:commentRss>http://wptheming.com/2010/07/portfolio-theme/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>Woo Real Estate Speculation</title>
		<link>http://wptheming.com/2010/07/woo-real-estate-speculation/</link>
		<comments>http://wptheming.com/2010/07/woo-real-estate-speculation/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 16:25:09 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Custom Post Types]]></category>

		<guid isPermaLink="false">http://wptheming.com/?p=909</guid>
		<description><![CDATA[Woo Themes announced that they are coming out with a <a href="http://www.woothemes.com/2010/07/realty-reality/">Real Estate theme</a> in the next 6-8 weeks.  I know there's a huge need for this- because I've built one based off the Canvas framework for a client.  Here's a screencast showing the theme.]]></description>
			<content:encoded><![CDATA[<p>Woo Themes announced that they are coming out with a new <a href="http://www.woothemes.com/2010/07/realty-reality/">Real Estate theme</a> in the next 6-8 weeks.  I&#8217;ve built multiple real estate sites for clients, so I know there&#8217;s a strong demand for this.  In fact, I recently built one of my own based on <a href="http://www.woothemes.com/amember/go.php?r=12019&#038;i=l64">Woo Theme&#8217;s Canvas</a> (affiliate).</p>
<h3>How a Real Estate Theme Might Work</h3>
<p>Any new real estate theme in WordPress will be taking advantage of custom post types for property listings and meta boxes to list the property details.  Here&#8217;s a walkthrough of the real estate theme I built, and my speculations on how the new Woo Theme might work:</p>
<p><a href="http://wptheming.com/2010/07/woo-real-estate-speculation/"><em>Click here to view the embedded video.</em></a></p>
<p>The service this theme was built for will be launched in the next few weeks at <a href="http://reitheme.com/">REI Theme</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://wptheming.com/2010/07/woo-real-estate-speculation/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Custom Post Type Resources</title>
		<link>http://wptheming.com/2010/07/custom-post-type-resources/</link>
		<comments>http://wptheming.com/2010/07/custom-post-type-resources/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 01:05:28 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Custom Post Types]]></category>
		<category><![CDATA[custom post types]]></category>

		<guid isPermaLink="false">http://wptheming.com/?p=859</guid>
		<description><![CDATA[The ability to create custom post types was a great feature added in WordPress 2.9 and then expanded in 3.0.  It allows us to add and label completely different types of content than the standard "Pages" and "Posts" we're all used to.  To get started with this, here's my recommended list of links and resources.]]></description>
			<content:encoded><![CDATA[<p><a href="http://wptheming.com/wp-content/uploads/2010/07/custom-post-types1.jpg"><img class="alignright size-full wp-image-864" title="custom-post-types" src="http://wptheming.com/wp-content/uploads/2010/07/custom-post-types1.jpg" alt="" width="205" height="119" /></a>The ability to create custom post types was a great feature added in WordPress 2.9 and then expanded in 3.0.  It allows us to create completely different types of content than the standard &#8220;Pages&#8221; and &#8220;Posts&#8221; we&#8217;re all used to.</p>
<p>To get started with custom post types, here&#8217;s my recommended list of links and resources:</p>
<h3>General Overview of Custom Post Types</h3>
<h4><a href="http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress">Custom post types in WordPress</a></h4>
<p>Justin Tadlock has the best all around reference guide for building custom post types. <a href="http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress">This article</a> has several code snippets and in-depth explanations of how to build custom post types, add taxomonies, and display the posts on your site.  There&#8217;s also a follow-up article explaining <a href="http://justintadlock.com/archives/2010/02/02/showing-custom-post-types-on-your-home-blog-page">how to display the custom post types</a> on your home page.</p>
<h4><a href="http://wpengineer.com/impressions-of-custom-post-type/">Custom Post Types by WP Engineer</a></h4>
<p>WP Engineer does really solid posts about new WordPress features.  This one has a <a href="http://wpengineer.com/impressions-of-custom-post-type/">list of the arguments</a> you might need when setting up a custom post type array.</p>
<h4><a href="http://codex.wordpress.org/Custom_Post_Types">WordPress Codex for Custom Post Types</a></h4>
<p>The WordPress codex has <a href="http://codex.wordpress.org/Custom_Post_Types">basic reference for custom post types</a>.</p>
<h3>Adding Meta Boxes to Custom Post Types</h3>
<p><img class="alignright size-full wp-image-873" title="custom-meta-boxes" src="http://wptheming.com/wp-content/uploads/2010/07/custom-meta-boxes.jpg" alt="" width="588" height="305" /></p>
<p>When you create a custom post type, you are able to specify which metaboxes are available on the edit screen.  The metaboxes generally included with the post are title, content, excerpt, and custom fields.</p>
<p>But if you&#8217;re using the post types in new or interesting way, you&#8217;ll likely need more custom metaboxes.  For instance, if you were making a real estate web site, you&#8217;d probably want the &#8220;Properties&#8221; custom post type to have boxes for entering the address, list price, amount of bedrooms, etc.  To add these, you&#8217;ll need to create new custom meta boxes.</p>
<h4><a href="http://www.deluxeblogtips.com/2010/04/how-to-create-meta-box-wordpress-post.html">How to create a Meta Box</a></h4>
<p>There&#8217;s several tutorials out there for creating custom meta boxes, and most of them will work for custom post types- even if it was written before WordPress 3.0 came out.  This <a href="http://www.deluxeblogtips.com/2010/04/how-to-create-meta-box-wordpress-post.html">post by Deluxe Blog Tips</a> in the most in-depth and well documented one I&#8217;ve found.</p>
<p>I&#8217;ve also found it helpful to look at the code from premium theme developers like WooThemes.  They have some really nice custom meta areas that are added to posts.  You can <a href="http://www.woothemes.com/2010/06/tma/">download one of their free themes</a> if you want to see how those are built.</p>
<h3>Custom Taxonomies</h3>
<h4><a href="http://justintadlock.com/archives/2010/06/10/a-refresher-on-custom-taxonomies">A Refresher on Custom Taxonomies</a></h4>
<p>You won&#8217;t be using custom post types for long before you realize there needs to be a way to organize them.  Pages and posts currently use categories and tags as taxonomies- but if you were making a post type called &#8220;Movies&#8221;, it might make sense to build a taxonomy for &#8220;Actors&#8221; to tag your posts in.  <a href="http://justintadlock.com/archives/2010/06/10/a-refresher-on-custom-taxonomies">This article by Justin Tadlock has code examples and explanations for using taxonomies</a>.</p>
<h4><a href="http://wordpress.mfields.org/taxonomy/">In Depth Explanation of Taxonomies</a></h4>
<p>If you still don&#8217;t quite understand what taxonomies are, I&#8217;d recommend checking out <a href="http://wordpress.mfields.org/taxonomy/">this article by Michael Fields</a>.  There&#8217;s also an entertaining screencast that explains what a taxonomy is and how you might use one.</p>
<h3>Other Tutorials</h3>
<p>Voosh Themes has a terrific tutorial for <a href="http://www.vooshthemes.com/blog/wordpress-tip/create-a-professional-portfolio-using-wordpress-3-0-custom-post-types/">creating a professional portfolio using custom post types</a>.</p>
<h3>Plug-Ins for Managing Custom Post Types</h3>
<h4><a href="http://wordpress.org/extend/plugins/simple-custom-post-type-archives/">Simple Custom Post Type Archives</a></h4>
<p>One problem with custom post types is a lack of templates.  Out of the box, WordPress only has support for single-customposttype.php.  If you have archives, or want a multiple listing, you&#8217;ll need to build the template redirects in or use a page template. <a href="http://www.cmurrayconsulting.com/software/wordpress-custom-post-type-archives/"> Jake Goldman built a plug-in to handle this issue</a>.  Michael Fields <a href="http://wordpress.mfields.org/2010/custom-content-type-add-theme-redirect/">wrote an article and code snippet</a> to address it.  And <a href="http://somadesign.ca/projects/smarter-custom-post-types/">Matt Weibe has a plugin that&#8217;s not in the repository</a>, but also handles the issues of redirects.</p>
<h4><a href="http://wordpress.org/extend/plugins/convert-post-types/">Convert Post Types</a></h4>
<p>Perhaps you have a lot of posts on your site, let&#8217;s say for a portfolio, that you now want to convert into a custom post type.  Rather than copying everything over by hand, you could use <a href="http://sillybean.net/wordpress/new-plugin-convert-post-types/">this handy plug-in</a>.  It&#8217;s also hosted in the <a href="http://wordpress.org/extend/plugins/convert-post-types/">WordPress repository</a>.</p>
<h4><a href="http://wordpress.org/extend/plugins/custom-post-type-ui/">Custom Post Type UI</a></h4>
<p>If you&#8217;re unfamiliar with PHP code, you can still add custom post types to your site.  Brad Williams of WebDevStudios made a nice user interface that allows you to <a href="http://wordpress.org/extend/plugins/custom-post-type-ui/">set up the custom post types and define the taxonomies</a>, all from the comfort of your WordPress dashboard.</p>
<h3>Themes and Plugins That Use Custom Post Types</h3>
<p>I expect we&#8217;ll see gallery, podcasting, and real estate themes soon- along with plugins for calendars, forums and e-commerce.</p>
<h4><a href="http://www.woothemes.com/amember/go.php?r=12019&#038;i=l80">Estate</a></h4>
<p><strong><a href="http://www.woothemes.com/amember/go.php?r=12019&#038;i=l80">Estate</a></strong> is a real estate theme by <a href="http://www.woothemes.com/amember/go.php?r=12019&amp;i=b16">Woo Themes</a> (affiliate link) that uses custom post types for property listings.</p>
<h4><a href="http://wptheming.com/2010/07/portfolio-theme/">Portfolio Theme</a></h4>
<p><a href="http://wptheming.com/2010/07/portfolio-theme/">Portfolio Theme</a> is a free GPL theme that I&#8217;ve released.  You can add various images to your portfolio post type to display them on your site.  It&#8217;s excellent for artists or web designers.  Feel free to look at the code and use it for your own projects.</p>
<h4><a href="http://getshopped.org/developers/custom-post-types/">WP E-Commerce</a></h4>
<p>The <a href="http://getshopped.org/developers/custom-post-types/">WP-Ecommerce Plugin</a> is scheduled to use custom post types in their next release.</p>
<h4><a href="http://wpbids.com/">WP Bids</a></h4>
<p><a href="http://wpbids.com/">WP Bids</a> uses a custom post type to generate client proposals and job estimates.</p>
<h4><a href="http://wordpress.org/extend/plugins/tb-testimonials/">TBTestimonials</a></h4>
<p>Manage your client testimonials with Custom Post Types. There&#8217;s even a spiffy widget.</p>
<h3>Add Your Own Links</h3>
<p>There&#8217;s still a lot of work being developed for custom post types.  If you notice a new tutorial, theme or plugin that I haven&#8217;t mentioned, please add it to the comments so I can put it in the post.</p>
]]></content:encoded>
			<wfw:commentRss>http://wptheming.com/2010/07/custom-post-type-resources/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Custom Post Types with Woo Themes</title>
		<link>http://wptheming.com/2010/07/woo-custom-post-type/</link>
		<comments>http://wptheming.com/2010/07/woo-custom-post-type/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 21:25:11 +0000</pubDate>
		<dc:creator>Devin</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://wptheming.com/?p=853</guid>
		<description><![CDATA[These code snippets will build a video post type with a taxonomy, complete with custom meta boxes adding additional information specific to the post type in Canvas.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re building a custom post type for a Woo Theme, there&#8217;s actually a lot of styles and functions you can use so your meta boxes match the Woo styling and work in the same way that Woo Custom Meta boxes do.</p>
<p>The code snippets below will build a video post type with a taxonomy, complete with custom meta boxes for adding additional information specific to the post type.</p>
<p>If you are looking for more information on how custom post types work, I&#8217;d highly recommend Justin Tadlock&#8217;s post on using <a href="http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress">Custom Post Types in WordPress</a>.</p>
<h3>Create a New File for You Custom Post Type Code</h3>
<p>There&#8217;s a lot of code here, so I would add this line to your the functions file of your child theme:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p853code25'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p85325"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p853code25"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
<span style="color: #666666; font-style: italic;">// Create Custom Post Types</span>
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
&nbsp;
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span>STYLESHEETPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/extensions/video-post-type.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Add the Code for Making the Custom Post Type</h3>
<p>Then create a folder called &#8220;extensions&#8221; in your child theme directory, and make a new file called &#8220;video-post-type.php&#8221;.  In that file add this code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p853code26'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p85326"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
</pre></td><td class="code" id="p853code26"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Plugin Name: Video Post Types
Plugin URI: http://www.wptheming.com
Description: Video post types for WordPress 3.0 and above.
Author: Devin Price
Version: 0.1
Author URI: http://wptheming.com
*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
<span style="color: #666666; font-style: italic;">// This plug-in adds a custom post type called &quot;videos&quot;</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// To run properly this plug-in should be used with Canvas by Woo Themes</span>
<span style="color: #666666; font-style: italic;">// http://www.woothemes.com/2010/02/canvas/</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// You can use a plug-in to create additional templates to display the post type.  Try:</span>
<span style="color: #666666; font-style: italic;">// http://www.cmurrayconsulting.com/software/wordpress-custom-post-type-archives/</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//  Use echo get_post_meta($post-&gt;ID, &quot;examplemetadata&quot;, true); to call the meta data</span>
<span style="color: #666666; font-style: italic;">//  within the post templates.</span>
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
<span style="color: #666666; font-style: italic;">// Registers the Video Post Types</span>
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> wpt_video_posttype<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	register_post_type<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'videos'</span><span style="color: #339933;">,</span>
		<a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Videos'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'singular_label'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Video'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'public'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'supports'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'editor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'excerpt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thumbnail'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'capability_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'slug'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'videos'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// Permalinks format</span>
			<span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'videos'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// This goes to the WP_Query schema</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpt_video_posttype'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
<span style="color: #666666; font-style: italic;">// Adds Custom Post Support for Thumbnails</span>
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
&nbsp;
add_theme_support<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post-thumbnails'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'videos'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
add_image_size<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'video-thumbnails'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">230</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">115</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
<span style="color: #666666; font-style: italic;">// Build the Taxonomies</span>
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wpt_create_db_taxonomies'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> wpt_create_db_taxonomies<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	register_taxonomy<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'video-category'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'videos'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Video Categories'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	register_taxonomy<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'video-tag'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'videos'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Video Tags'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
<span style="color: #666666; font-style: italic;">// Adds Meta Boxes to Video Edit Screen</span>
<span style="color: #666666; font-style: italic;">// Relies on Canvas specific functions</span>
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> video_content_metabox_add<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/function_exists"><span style="color: #990000;">function_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'add_meta_box'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        add_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'woothemes-video-settings'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Video Settings'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'video_posts_metabox_create'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'videos'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		add_meta_box<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'woothemes-settings'</span><span style="color: #339933;">,</span>get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'woo_themename'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' Custom Settings'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'woothemes_metabox_create'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'videos'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_menu'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'video_content_metabox_add'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Triggers video_posts_metabox_create</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
<span style="color: #666666; font-style: italic;">// Custom fields for WP write panel</span>
<span style="color: #666666; font-style: italic;">// This code is protected under Creative Commons License: http://creativecommons.org/licenses/by-nc-nd/3.0/</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//  This was duplicated from functions/admin-custom.php to load the new metabox</span>
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> video_posts_metabox_create<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$woo_metaboxes</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'woo_video_template'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
    <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;table class=&quot;woo_metaboxes_table&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metaboxes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$woo_id</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>        
                <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'text'</span> 
		OR      <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'select'</span> 
		OR      <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'checkbox'</span> 
		OR      <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'textarea'</span>
		OR      <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'calendar'</span>
		OR      <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'radio'</span>
		OR      <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'images'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$woo_metaboxvalue</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metaboxvalue</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'std'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$woo_metaboxvalue</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'std'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'text'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;tr&gt;'</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;th class=&quot;woo_metabox_names&quot;&gt;&lt;label for=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/label&gt;&lt;/th&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;td&gt;&lt;input class=&quot;woo_input_text&quot; type=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; value=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metaboxvalue</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; name=&quot;woothemes_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; id=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;/&gt;'</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;span class=&quot;woo_metabox_desc&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'desc'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/span&gt;&lt;/td&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>  
&nbsp;
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'textarea'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;tr&gt;'</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;th class=&quot;woo_metabox_names&quot;&gt;&lt;label for=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/label&gt;&lt;/th&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;td&gt;&lt;textarea class=&quot;woo_input_textarea&quot; name=&quot;woothemes_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; id=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$woo_metaboxvalue</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/textarea&gt;'</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;span class=&quot;woo_metabox_desc&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'desc'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/span&gt;&lt;/td&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>  
&nbsp;
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'calendar'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;tr&gt;'</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;th class=&quot;woo_metabox_names&quot;&gt;&lt;label for=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/label&gt;&lt;/th&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;td&gt;&lt;input class=&quot;woo_input_calendar&quot; type=&quot;text&quot; name=&quot;woothemes_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; id=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; value=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metaboxvalue</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;span class=&quot;woo_metabox_desc&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'desc'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/span&gt;&lt;/td&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>  
&nbsp;
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'select'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;tr&gt;'</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;th class=&quot;woo_metabox_names&quot;&gt;&lt;label for=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/label&gt;&lt;/th&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;td&gt;&lt;select class=&quot;woo_input_select&quot; id=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; name=&quot;woothemes_'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;option value=&quot;&quot;&gt;Select to return to default&lt;/option&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'options'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
                    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$id</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$option</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000088;">$selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
                        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'default'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>                            
							<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'default'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$option</span> <span style="color: #339933;">&amp;&amp;</span> <a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metaboxvalue</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> 
							<span style="color: #b1b100;">else</span>  <span style="color: #009900;">&#123;</span><span style="color: #000088;">$selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span>
&nbsp;
                        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metaboxvalue</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$option</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'selected=&quot;selected&quot;'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
                        <span style="color: #b1b100;">else</span>  <span style="color: #009900;">&#123;</span><span style="color: #000088;">$selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>  
&nbsp;
                        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;option value=&quot;'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$option</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; '</span><span style="color: #339933;">.</span> <span style="color: #000088;">$selected</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$option</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/option&gt;'</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;/select&gt;&lt;span class=&quot;woo_metabox_desc&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'desc'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/span&gt;&lt;/td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/tr&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'checkbox'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metaboxvalue</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'true'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$checked</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' checked=&quot;checked&quot;'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><span style="color: #000088;">$checked</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;tr&gt;'</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;th class=&quot;woo_metabox_names&quot;&gt;&lt;label for=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/label&gt;&lt;/th&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;td&gt;&lt;input type=&quot;checkbox&quot; '</span><span style="color: #339933;">.</span><span style="color: #000088;">$checked</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' class=&quot;woo_input_checkbox&quot; value=&quot;true&quot;  id=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; name=&quot;woothemes_'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;span class=&quot;woo_metabox_desc&quot; style=&quot;display:inline&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'desc'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/span&gt;&lt;/td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/tr&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'radio'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'options'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;tr&gt;'</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;th class=&quot;woo_metabox_names&quot;&gt;&lt;label for=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/label&gt;&lt;/th&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;td&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$id</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$option</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
                    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metaboxvalue</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$checked</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' checked'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><span style="color: #000088;">$checked</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
&nbsp;
                        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;input type=&quot;radio&quot; '</span><span style="color: #339933;">.</span><span style="color: #000088;">$checked</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' value=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; class=&quot;woo_input_radio&quot;  name=&quot;woothemes_'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;span class=&quot;woo_input_radio_desc&quot; style=&quot;display:inline&quot;&gt;'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$option</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/span&gt;&lt;div class=&quot;woo_spacer&quot;&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span>  <span style="color: #0000ff;">'&lt;/td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/tr&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>    
                 <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'images'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$select_value</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$layout</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'options'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$option</span><span style="color: #009900;">&#41;</span> 
				 <span style="color: #009900;">&#123;</span> 
				 <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
&nbsp;
				 <span style="color: #000088;">$checked</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
				 <span style="color: #000088;">$selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
				 <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metaboxvalue</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				 	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metaboxvalue</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$checked</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' checked'</span><span style="color: #339933;">;</span> <span style="color: #000088;">$selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'woo-meta-radio-img-selected'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
				 <span style="color: #009900;">&#125;</span> 
				 <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
				 	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$option</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'std'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$checked</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' checked'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> 
					<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$checked</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' checked'</span><span style="color: #339933;">;</span> <span style="color: #000088;">$selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'woo-meta-radio-img-selected'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
					<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$checked</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
				 <span style="color: #009900;">&#125;</span>
&nbsp;
					<span style="color: #000088;">$layout</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;div class=&quot;woo-meta-radio-img-label&quot;&gt;'</span><span style="color: #339933;">;</span>			
					<span style="color: #000088;">$layout</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;input type=&quot;radio&quot; id=&quot;woo-meta-radio-img-'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; class=&quot;checkbox woo-meta-radio-img-radio&quot; value=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$key</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; name=&quot;woothemes_'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; '</span><span style="color: #339933;">.</span><span style="color: #000088;">$checked</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' /&gt;'</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$layout</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&amp;nbsp;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;div class=&quot;woo_spacer&quot;&gt;&lt;/div&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$layout</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$option</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; alt=&quot;&quot; class=&quot;woo-meta-radio-img-img '</span><span style="color: #339933;">.</span> <span style="color: #000088;">$selected</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; onClick=&quot;document.getElementById(\'woo-meta-radio-img-'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'\').checked = true;&quot; /&gt;'</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;tr&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;th class=&quot;woo_metabox_names&quot;&gt;&lt;label for=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/label&gt;&lt;/th&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;td class=&quot;woo_metabox_fields&quot;&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$layout</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;span class=&quot;woo_metabox_desc&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'desc'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/span&gt;&lt;/td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;/td&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/tr&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'upload'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;default&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$default</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;default&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">else</span> <span style="color: #000088;">$default</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;tr&gt;'</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;th class=&quot;woo_metabox_names&quot;&gt;&lt;label for=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/label&gt;&lt;/th&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;td class=&quot;woo_metabox_fields&quot;&gt;'</span><span style="color: #339933;">.</span> woothemes_uploader_custom_fields<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$default</span><span style="color: #339933;">,</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;desc&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;/td&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/tr&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;/table&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
<span style="color: #666666; font-style: italic;">// Adds the Video Metabox Options</span>
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_head'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'video_add_custom'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> video_add_custom<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Video Metabox Options</span>
	<span style="color: #000088;">$video_metaboxes</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
&nbsp;
	<span style="color: #0000ff;">&quot;thumbail&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a> <span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">&quot;name&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;thumbnail&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;label&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Video Thumbnail&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;type&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;upload&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;desc&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Upload file here...&quot;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;videoembed&quot;</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a> <span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">&quot;name&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;videoembed&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;label&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Video Embed Code&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;type&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;textarea&quot;</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;desc&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;This will be used on the video post page.&quot;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
&nbsp;
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
update_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'woo_video_template'</span><span style="color: #339933;">,</span><span style="color: #000088;">$video_metaboxes</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
<span style="color: #666666; font-style: italic;">// Saves the metabox fields to the WooTheme Options</span>
<span style="color: #666666; font-style: italic;">// Duplicates the woothemes function woothemes_metabox_handle ()</span>
<span style="color: #666666; font-style: italic;">/*-----------------------------------------------------------------------------------*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> video_metabox_handle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>   
&nbsp;
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$globals</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$woo_metaboxes</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'woo_video_template'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_ID'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$pID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_ID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$upload_tracking</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'editpost'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>                                   
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metaboxes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// On Save.. this gets looped in the header response and saves the values submitted</span>
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'text'</span> 
			OR <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'calendar'</span> 
			OR <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'select'</span> 
			OR <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'radio'</span>
			OR <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'checkbox'</span> 
			OR <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'textarea'</span> 
			OR <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'images'</span> <span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Normal Type Things...</span>
                <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;woothemes_&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>            
                        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> get_post_meta<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$pID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #009900;">&#41;</span>
                            add_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                            update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                           delete_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>
                    <span style="color: #009900;">&#125;</span>
                    <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'checkbox'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
                        update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'false'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
                    <span style="color: #009900;">&#125;</span>      
                    <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                          delete_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Deletes check boxes OR no $_POST</span>
                    <span style="color: #009900;">&#125;</span>    
                <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'upload'</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// So, the upload inputs will do this rather</span>
                <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$override</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'editpost'</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attachement_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//New upload          </span>
                           <span style="color: #000088;">$uploaded_file</span> <span style="color: #339933;">=</span> wp_handle_upload<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attachement_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$id</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$override</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
                           <span style="color: #000088;">$uploaded_file</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'option_name'</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$woo_metabox</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'label'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                           <span style="color: #000088;">$upload_tracking</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$uploaded_file</span><span style="color: #339933;">;</span>
                           update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$uploaded_file</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                    <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attachement_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span> <span style="color: #000088;">$id</span> <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                        update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span> <span style="color: #000088;">$id</span> <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
                    <span style="color: #009900;">&#125;</span>
                    <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span> <span style="color: #000088;">$id</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span> delete_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id</span><span style="color: #339933;">,</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$pID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
               <span style="color: #666666; font-style: italic;">// Error Tracking - File upload was not an Image</span>
               update_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'woo_custom_upload_tracking'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$upload_tracking</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit_post'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'video_metabox_handle'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h3>Displaying That Information in a Template</h3>
<p>Great.  Now you&#8217;ve got the new video post type built, along with meta boxes for the video embed code and a thumbnail image.  To display the video when you visit go to that custom post type, you could create a new template called single-video.php- and paste the following:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p853code27'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p85327"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
</pre></td><td class="code" id="p853code27"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
    <span style="color: #339933;">&lt;!--</span> <span style="color: #666666; font-style: italic;">#content Starts --&gt;
</span>	<span style="color: #000000; font-weight: bold;">&lt;?php</span> woo_content_before<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;content&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;col-full&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
    	<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;main-sidebar-container&quot;</span><span style="color: #339933;">&gt;</span>    
&nbsp;
            <span style="color: #339933;">&lt;!--</span> <span style="color: #666666; font-style: italic;">#main Starts --&gt;
</span>            <span style="color: #000000; font-weight: bold;">&lt;?php</span> woo_main_before<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
            <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;main&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
                <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
                <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$count</span><span style="color: #339933;">++;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
                <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;videoembed&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
                <span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
				<span style="color: #000088;">$video_embed_code</span> <span style="color: #339933;">=</span>  get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;videoembed&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$video_embed_code</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
                	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$video_embed_code</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    				the_post_thumbnail<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">640</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">9999</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
                <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
                 <span style="color: #339933;">&lt;!--</span> Post Starts <span style="color: #339933;">--&gt;</span>
                <span style="color: #000000; font-weight: bold;">&lt;?php</span> woo_post_before<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&nbsp;
&nbsp;
                <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">&lt;?php</span> post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
                    <span style="color: #000000; font-weight: bold;">&lt;?php</span> woo_post_inside_before<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&nbsp;
                    <span style="color: #339933;">&lt;</span>h1 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;title&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h1<span style="color: #339933;">&gt;</span>
&nbsp;
                    <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
                        <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&nbsp;
       			    <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;clear&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
                    <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">/.</span>entry <span style="color: #339933;">--&gt;</span>
&nbsp;
                    <span style="color: #000000; font-weight: bold;">&lt;?php</span> edit_post_link<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'{ Edit }'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'woothemes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;span class=&quot;small&quot;&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
                    <span style="color: #000000; font-weight: bold;">&lt;?php</span> woo_post_inside_after<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
                <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">/.</span>post <span style="color: #339933;">--&gt;</span>
                <span style="color: #000000; font-weight: bold;">&lt;?php</span> woo_post_after<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
                <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$comm</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'woo_comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'open'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_status</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$comm</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;page&quot;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$comm</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;both&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
                    <span style="color: #000000; font-weight: bold;">&lt;?php</span> comments_template<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
                <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">else</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
                <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post&quot;</span><span style="color: #339933;">&gt;</span>
                    <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Sorry, no posts matched your criteria.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'woothemes'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
                <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">/.</span>post <span style="color: #339933;">--&gt;</span>
            <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  
&nbsp;
            <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">/</span><span style="color: #666666; font-style: italic;">#main --&gt;
</span>            <span style="color: #000000; font-weight: bold;">&lt;?php</span> woo_main_after<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">&lt;?php</span> get_sidebar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
		<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">/</span><span style="color: #666666; font-style: italic;">#main-sidebar-container --&gt;         
</span>
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_sidebar<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'alt'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
    <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">/</span><span style="color: #666666; font-style: italic;">#content --&gt;
</span>	<span style="color: #000000; font-weight: bold;">&lt;?php</span> woo_content_after<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_footer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>In this code I duplicated a lot of the WooThemes functions so that I could alter them in the child theme.  If you don&#8217;t want to duplicate the code, you could just build the meta boxes directly into the panel rather than relying on the WooThemes code.  <a href="http://www.deluxeblogtips.com/2010/04/how-to-create-meta-box-wordpress-post.html">Read this post from Dulexe Blog Tips</a> for more information on how to do this.</p>
]]></content:encoded>
			<wfw:commentRss>http://wptheming.com/2010/07/woo-custom-post-type/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)

Served from: wptheming.com @ 2010-09-05 21:02:42 -->
