<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Creating User Friendly Custom Fields by Modifying the Post Page</title>
	<atom:link href="http://apartmentonesix.com/2009/03/creating-user-friendly-custom-fields-by-modifying-the-post-page/feed/" rel="self" type="application/rss+xml" />
	<link>http://apartmentonesix.com/2009/03/creating-user-friendly-custom-fields-by-modifying-the-post-page/</link>
	<description></description>
	<lastBuildDate>Thu, 14 Jan 2010 18:35:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Darrell</title>
		<link>http://apartmentonesix.com/2009/03/creating-user-friendly-custom-fields-by-modifying-the-post-page/comment-page-1/#comment-1981</link>
		<dc:creator>Darrell</dc:creator>
		<pubDate>Tue, 18 Aug 2009 02:19:32 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=78#comment-1981</guid>
		<description>Hello, I am trying to add a page to my website that would allow visitors to post things like their name and school, and have this info to post right away...

Do you know where I can get this info????????</description>
		<content:encoded><![CDATA[<p>Hello, I am trying to add a page to my website that would allow visitors to post things like their name and school, and have this info to post right away&#8230;</p>
<p>Do you know where I can get this info????????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://apartmentonesix.com/2009/03/creating-user-friendly-custom-fields-by-modifying-the-post-page/comment-page-1/#comment-101</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Fri, 17 Apr 2009 00:03:25 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=78#comment-101</guid>
		<description>Very cool Havard - I noticed in the core that if the meta  value is an array, it won&#039;t be displayed, but I had no idea you could do it this way as well.  Thanks for the tip!</description>
		<content:encoded><![CDATA[<p>Very cool Havard &#8211; I noticed in the core that if the meta  value is an array, it won&#8217;t be displayed, but I had no idea you could do it this way as well.  Thanks for the tip!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Håvard Fossli</title>
		<link>http://apartmentonesix.com/2009/03/creating-user-friendly-custom-fields-by-modifying-the-post-page/comment-page-1/#comment-100</link>
		<dc:creator>Håvard Fossli</dc:creator>
		<pubDate>Thu, 16 Apr 2009 23:21:29 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=78#comment-100</guid>
		<description>a good tip. 
if you don&#039;t like that the meta is automatically retrieved in the postedior then set the meta_key with underscore as prefix (&quot;_metakeyname&quot;) and it is not visible. :)</description>
		<content:encoded><![CDATA[<p>a good tip.<br />
if you don&#8217;t like that the meta is automatically retrieved in the postedior then set the meta_key with underscore as prefix (&#8220;_metakeyname&#8221;) and it is not visible. <img src='http://apartmentonesix.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://apartmentonesix.com/2009/03/creating-user-friendly-custom-fields-by-modifying-the-post-page/comment-page-1/#comment-83</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Thu, 09 Apr 2009 04:21:31 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=78#comment-83</guid>
		<description>Hey Rogerio - 

The CSS disappearing is no accident - read about it here: &lt;a href=&quot;http://naked.dustindiaz.com/&quot; rel=&quot;nofollow&quot;&gt;Annual CSS Naked Day&lt;/a&gt;.  Should be back to normal after tomorrow.

Thanks!</description>
		<content:encoded><![CDATA[<p>Hey Rogerio &#8211; </p>
<p>The CSS disappearing is no accident &#8211; read about it here: <a href="http://naked.dustindiaz.com/" rel="nofollow">Annual CSS Naked Day</a>.  Should be back to normal after tomorrow.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rogério Madureira</title>
		<link>http://apartmentonesix.com/2009/03/creating-user-friendly-custom-fields-by-modifying-the-post-page/comment-page-1/#comment-81</link>
		<dc:creator>Rogério Madureira</dc:creator>
		<pubDate>Wed, 08 Apr 2009 22:13:51 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=78#comment-81</guid>
		<description>I guess the css of the site is not loading...</description>
		<content:encoded><![CDATA[<p>I guess the css of the site is not loading&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rogério Madureira</title>
		<link>http://apartmentonesix.com/2009/03/creating-user-friendly-custom-fields-by-modifying-the-post-page/comment-page-1/#comment-77</link>
		<dc:creator>Rogério Madureira</dc:creator>
		<pubDate>Wed, 08 Apr 2009 12:56:29 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=78#comment-77</guid>
		<description>Have you ever tried pastie.org? I found it the best solution for pasting the code on the net. 

</description>
		<content:encoded><![CDATA[<p>Have you ever tried pastie.org? I found it the best solution for pasting the code on the net.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://apartmentonesix.com/2009/03/creating-user-friendly-custom-fields-by-modifying-the-post-page/comment-page-1/#comment-73</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Tue, 07 Apr 2009 23:24:11 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=78#comment-73</guid>
		<description>Thanks  Rogério - 
I have an enormous amount of trouble getting source code to format properly:  blocks of php were being removed from my code.  Hopefully I&#039;ll get better at it soon.

In the meantime, I&#039;ve updated the code, and tested the posted version - it should be working now.

Thanks for the reference you posted - should be a great resource for anyone who needs more help with this.</description>
		<content:encoded><![CDATA[<p>Thanks  Rogério &#8211;<br />
I have an enormous amount of trouble getting source code to format properly:  blocks of php were being removed from my code.  Hopefully I&#8217;ll get better at it soon.</p>
<p>In the meantime, I&#8217;ve updated the code, and tested the posted version &#8211; it should be working now.</p>
<p>Thanks for the reference you posted &#8211; should be a great resource for anyone who needs more help with this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rogério Madureira</title>
		<link>http://apartmentonesix.com/2009/03/creating-user-friendly-custom-fields-by-modifying-the-post-page/comment-page-1/#comment-71</link>
		<dc:creator>Rogério Madureira</dc:creator>
		<pubDate>Tue, 07 Apr 2009 22:25:07 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=78#comment-71</guid>
		<description>Peter, thank you for you prompt reply.

It looks there&#039;s a missing &quot;&lt;?&quot; on line 25, among &quot;&quot; and &quot;}&quot;

The explanation about &quot;add meta box function&quot; in the Wordpress Codex  http://codex.wordpress.org/Function_Reference/add_meta_box
is much more complicated, though there is a security verification we are not doing.

Well, I have changed your code a bit in order to achieve my needs and added all reference I could find about the needed functions: http://pastie.org/440128

Once more, thank you.</description>
		<content:encoded><![CDATA[<p>Peter, thank you for you prompt reply.</p>
<p>It looks there&#8217;s a missing &#8220;&lt;?&#8221; on line 25, among &#8220;&#8221; and &#8220;}&#8221;</p>
<p>The explanation about &#8220;add meta box function&#8221; in the Wordpress Codex  <a href="http://codex.wordpress.org/Function_Reference/add_meta_box" rel="nofollow">http://codex.wordpress.org/Function_Reference/add_meta_box</a><br />
is much more complicated, though there is a security verification we are not doing.</p>
<p>Well, I have changed your code a bit in order to achieve my needs and added all reference I could find about the needed functions: <a href="http://pastie.org/440128" rel="nofollow">http://pastie.org/440128</a></p>
<p>Once more, thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://apartmentonesix.com/2009/03/creating-user-friendly-custom-fields-by-modifying-the-post-page/comment-page-1/#comment-69</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Tue, 07 Apr 2009 19:51:23 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=78#comment-69</guid>
		<description>Hi  Rogério - 
Thanks for the kind words, I&#039;m glad you liked the post.  To answer your question:


$postID is passed in via this line:


add_action(&#039;save_post&#039;, &#039;custom_add_save&#039;);


The save_post action hook (see a complete list of action hooks &lt;a href=&quot;http://codex.wordpress.org/Plugin_API/Action_Reference&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;) passes in the post id of the post that is being saved.  So whenever you save a post, this action will call your function (in this case, custom_add_save), with the post id as the first parameter.

We then use the post id that has been passed in to find the parent id with the function &lt;a href=&quot;http://xref.apartmentonesix.com/2.7.1/wp-includes/post.php.source.html#l3400&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;wp_is_post_revision()&lt;/a&gt;.  wp_is_post_revision will return a post id (which will evaluate to true in an if statement) if the post is a revision, or false if it is the original post.  So, with this line:
if($parent_id = wp_is_post_revision($postID)){
$postID = $parent_id;
}
we check if the post is a revision, and if it is, we set the $postID variable to the post id of the parent post, because this is the one we want.

At this point, however, something is definitely wrong -  I forgot to change the $_POST variables that get checked to match the rest of the code.  At this point, you want to check each of your options to see if they&#039;ve been posted - instead of if($_POST[&#039;columns&#039;]), it should be 
if ($_POST[&#039;cpi_dropdown_options&#039;])
and 
if ($_POST[&#039;cpi_text_option&#039;]) {

I&#039;ve changed the code in the post to be accurate.

Good luck!</description>
		<content:encoded><![CDATA[<p>Hi  Rogério &#8211;<br />
Thanks for the kind words, I&#8217;m glad you liked the post.  To answer your question:</p>
<p>$postID is passed in via this line:</p>
<p>add_action(&#8217;save_post&#8217;, &#8216;custom_add_save&#8217;);</p>
<p>The save_post action hook (see a complete list of action hooks <a href="http://codex.wordpress.org/Plugin_API/Action_Reference" rel="nofollow">here</a>) passes in the post id of the post that is being saved.  So whenever you save a post, this action will call your function (in this case, custom_add_save), with the post id as the first parameter.</p>
<p>We then use the post id that has been passed in to find the parent id with the function <a href="http://xref.apartmentonesix.com/2.7.1/wp-includes/post.php.source.html#l3400" target="_blank" rel="nofollow">wp_is_post_revision()</a>.  wp_is_post_revision will return a post id (which will evaluate to true in an if statement) if the post is a revision, or false if it is the original post.  So, with this line:<br />
if($parent_id = wp_is_post_revision($postID)){<br />
$postID = $parent_id;<br />
}<br />
we check if the post is a revision, and if it is, we set the $postID variable to the post id of the parent post, because this is the one we want.</p>
<p>At this point, however, something is definitely wrong &#8211;  I forgot to change the $_POST variables that get checked to match the rest of the code.  At this point, you want to check each of your options to see if they&#8217;ve been posted &#8211; instead of if($_POST['columns']), it should be<br />
if ($_POST['cpi_dropdown_options'])<br />
and<br />
if ($_POST['cpi_text_option']) {</p>
<p>I&#8217;ve changed the code in the post to be accurate.</p>
<p>Good luck!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rogério Madureira</title>
		<link>http://apartmentonesix.com/2009/03/creating-user-friendly-custom-fields-by-modifying-the-post-page/comment-page-1/#comment-68</link>
		<dc:creator>Rogério Madureira</dc:creator>
		<pubDate>Tue, 07 Apr 2009 19:29:15 +0000</pubDate>
		<guid isPermaLink="false">http://apartmentonesix.com/?p=78#comment-68</guid>
		<description>Hi. Congratulations, you have written the most comprehensive tutorial about the add_meta_box(). 

However, and please excuse me if I am wrong, it looks that it is missing something in the final part of your code. For example, where &quot;$parent_id&quot; and &quot;$postID&quot; is coming from?

function custom_add_save($postID){
	// called after a post or page is saved
	if($parent_id = wp_is_post_revision($postID)){
		$postID = $parent_id;
	}

	if($_POST[&#039;columns&#039;]){
		update_custom_meta($postID, $_POST[&#039;columns&#039;], &#039;columns&#039;);
	}
}</description>
		<content:encoded><![CDATA[<p>Hi. Congratulations, you have written the most comprehensive tutorial about the add_meta_box(). </p>
<p>However, and please excuse me if I am wrong, it looks that it is missing something in the final part of your code. For example, where &#8220;$parent_id&#8221; and &#8220;$postID&#8221; is coming from?</p>
<p>function custom_add_save($postID){<br />
	// called after a post or page is saved<br />
	if($parent_id = wp_is_post_revision($postID)){<br />
		$postID = $parent_id;<br />
	}</p>
<p>	if($_POST['columns']){<br />
		update_custom_meta($postID, $_POST['columns'], &#8216;columns&#8217;);<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>
