<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<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">
	<channel>
		<title>Gravity Support Forums Topic: Custom Fields</title>
		<link>https://legacy.forums.gravityhelp.com/topic/custom-fields-4</link>
		<description>Gravity Support Forums Topic: Custom Fields</description>
		<language>en-US</language>
		<pubDate>Sun, 19 Apr 2026 23:18:33 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/custom-fields-4" rel="self" type="application/rss+xml" />

		<item>
			<title>David Smith on "Custom Fields"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/custom-fields-4#post-44131</link>
			<pubDate>Thu, 15 Dec 2011 07:03:51 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">44131@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Great! Glad you were able to get this resolved. :)&#60;/p&#62;
&#60;p&#62;I'm going to close this topic now; but feel free to post a new topic if any other questions come up.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Custom Fields"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/custom-fields-4#post-44125</link>
			<pubDate>Thu, 15 Dec 2011 05:19:42 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">44125@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi David,&#60;/p&#62;
&#60;p&#62;The original tutorial is this one:&#60;br /&#62;
&#60;a href=&#34;http://wefunction.com/2009/10/revisited-creating-custom-write-panels-in-wordpress/&#34; rel=&#34;nofollow&#34;&#62;http://wefunction.com/2009/10/revisited-creating-custom-write-panels-in-wordpress/&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I've actually managed to modify the code so that each custom field creates a new row in the database - as I understand it, although this will add extra load on the database, this will make the data/fields more easily searchable and usable (for creating custom field archives, filters, etc.)&#60;/p&#62;
&#60;p&#62;For anyone else having a similar issue here's the new, modified code, which GF can pick up:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;/* Custom Fields */
$key = &#38;quot;key&#38;quot;;
$meta_boxes = array(
&#38;quot;cf_link&#38;quot; =&#38;gt; array(
&#38;quot;name&#38;quot; =&#38;gt; &#38;quot;cf_link&#38;quot;,
&#38;quot;title&#38;quot; =&#38;gt; &#38;quot;URL/Link&#38;quot;,
&#38;quot;description&#38;quot; =&#38;gt; &#38;quot;Enter the URL/Link here.&#38;quot;),
&#38;quot;cf_image&#38;quot; =&#38;gt; array(
&#38;quot;name&#38;quot; =&#38;gt; &#38;quot;cf_image&#38;quot;,
&#38;quot;title&#38;quot; =&#38;gt; &#38;quot;Image&#38;quot;,
&#38;quot;description&#38;quot; =&#38;gt; &#38;quot;Enter the image URL here.&#38;quot;),
&#38;quot;cf_instructions&#38;quot; =&#38;gt; array(
&#38;quot;name&#38;quot; =&#38;gt; &#38;quot;cf_instructions&#38;quot;,
&#38;quot;title&#38;quot; =&#38;gt; &#38;quot;Instructions&#38;quot;,
&#38;quot;type&#38;quot; =&#38;gt; &#38;quot;textarea&#38;quot;,
&#38;quot;description&#38;quot; =&#38;gt; &#38;quot;Enter any specific instructions here.&#38;quot;)
);

function create_meta_box() {
global $key;

if( function_exists( &#38;#39;add_meta_box&#38;#39; ) ) {
add_meta_box( &#38;#39;new-meta-boxes&#38;#39;, ucfirst( $key ) . &#38;#39;Product Details&#38;#39;, &#38;#39;display_meta_box&#38;#39;, &#38;#39;products&#38;#39;, &#38;#39;normal&#38;#39;, &#38;#39;high&#38;#39; );
}
}

function display_meta_box() {
    global $post, $meta_boxes, $key;
?&#38;gt;
    &#38;lt;div class=&#38;quot;form-wrap&#38;quot;&#38;gt;
&#38;lt;?php
    wp_nonce_field( plugin_basename( __FILE__ ), $key . &#38;#39;_wpnonce&#38;#39;, false, true );

    foreach($meta_boxes as $meta_box) {
        $data = get_post_meta($post-&#38;gt;ID, $meta_box[&#38;#39;name&#38;#39;], true);
?&#38;gt;
    &#38;lt;div class=&#38;quot;form-field form-required&#38;quot;&#38;gt;
    &#38;lt;label for=&#38;quot;&#38;lt;?php echo $meta_box[ &#38;#39;name&#38;#39; ]; ?&#38;gt;&#38;quot;&#38;gt;&#38;lt;?php echo $meta_box[ &#38;#39;title&#38;#39; ]; ?&#38;gt;&#38;lt;/label&#38;gt;
&#38;lt;?php if( $meta_box[&#38;#39;type&#38;#39;] === &#38;#39;textarea&#38;#39; ) { ?&#38;gt;
  &#38;lt;textarea name=&#38;quot;&#38;lt;?php echo $meta_box[ &#38;#39;name&#38;#39; ];?&#38;gt;&#38;quot; rows=&#38;quot;4&#38;quot;&#38;gt;&#38;lt;?php echo htmlspecialchars($data); ?&#38;gt;&#38;lt;/textarea&#38;gt; 

&#38;lt;?php } else { ?&#38;gt;

  &#38;lt;input type=&#38;quot;text&#38;quot; name=&#38;quot;&#38;lt;?php echo $meta_box[&#38;#39;name&#38;#39;]; ?&#38;gt;&#38;quot;
      value=&#38;quot;&#38;lt;?php echo htmlspecialchars($data); ?&#38;gt;&#38;quot; /&#38;gt;&#38;lt;?php }?&#38;gt;
&#38;lt;p&#38;gt;&#38;lt;?php echo $meta_box[ &#38;#39;description&#38;#39; ]; ?&#38;gt;&#38;lt;/p&#38;gt;
&#38;lt;/div&#38;gt;
&#38;lt;?php } ?&#38;gt;
&#38;lt;/div&#38;gt;

&#38;lt;?php
}

function save_meta_box( $post_id ) {
global $post, $meta_boxes, $key;

foreach( $meta_boxes as $meta_box ) {
$data[ $meta_box[ &#38;#39;name&#38;#39; ] ] = $_POST[ $meta_box[ &#38;#39;name&#38;#39; ] ];
}

if ( !wp_verify_nonce( $_POST[ $key . &#38;#39;_wpnonce&#38;#39; ], plugin_basename(__FILE__) ) )
return $post_id;

if ( !current_user_can( &#38;#39;edit_post&#38;#39;, $post_id ))
return $post_id;

foreach ($data as $d =&#38;gt; $v) {
        update_post_meta( $post_id, $d, $v );
    }
}

add_action( &#38;#39;admin_menu&#38;#39;, &#38;#39;create_meta_box&#38;#39; );
add_action( &#38;#39;save_post&#38;#39;, &#38;#39;save_meta_box&#38;#39; );&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>David Smith on "Custom Fields"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/custom-fields-4#post-44059</link>
			<pubDate>Wed, 14 Dec 2011 19:28:25 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">44059@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi ideaboxx,&#60;/p&#62;
&#60;p&#62;What tutorial did you follow to get this started? That will help in determining who to best assist you from here. :)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Custom Fields"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/custom-fields-4#post-43567</link>
			<pubDate>Fri, 09 Dec 2011 16:48:14 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">43567@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I have the following custom function code which i'm using to create custom fields for a custom post type.&#60;/p&#62;
&#60;p&#62;The issues is that I need the custom fields to show up individually and at the moment they just show up as 'key' which means that when i try to link a form field (Gravity Forms) to a custom field, I can only link to the 'key' field.&#60;/p&#62;
&#60;p&#62;Can anyone assist with how this can be modified to show each custom field individually so that Gravity Forms can pick up the individual Custom fields?&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;/* Custom Fields */
$key = &#38;quot;key&#38;quot;;
$meta_boxes = array(
&#38;quot;cf_link&#38;quot; =&#38;gt; array(
&#38;quot;name&#38;quot; =&#38;gt; &#38;quot;cf_link&#38;quot;,
&#38;quot;title&#38;quot; =&#38;gt; &#38;quot;URL/Link&#38;quot;,
&#38;quot;description&#38;quot; =&#38;gt; &#38;quot;Enter the URL/Link here.&#38;quot;),
&#38;quot;cf_image&#38;quot; =&#38;gt; array(
&#38;quot;name&#38;quot; =&#38;gt; &#38;quot;cf_image&#38;quot;,
&#38;quot;title&#38;quot; =&#38;gt; &#38;quot;Image&#38;quot;,
&#38;quot;description&#38;quot; =&#38;gt; &#38;quot;Enter the image URL here.&#38;quot;),
&#38;quot;cf_instructions&#38;quot; =&#38;gt; array(
&#38;quot;name&#38;quot; =&#38;gt; &#38;quot;cf_instructions&#38;quot;,
&#38;quot;title&#38;quot; =&#38;gt; &#38;quot;Instructions&#38;quot;,
&#38;quot;type&#38;quot; =&#38;gt; &#38;quot;textarea&#38;quot;,
&#38;quot;description&#38;quot; =&#38;gt; &#38;quot;Enter any specific instructions here.&#38;quot;)
);

function create_meta_box() {
global $key;

if( function_exists( &#38;#39;add_meta_box&#38;#39; ) ) {
add_meta_box( &#38;#39;new-meta-boxes&#38;#39;, ucfirst( $key ) . &#38;#39;Product Details&#38;#39;, &#38;#39;display_meta_box&#38;#39;, &#38;#39;products&#38;#39;, &#38;#39;normal&#38;#39;, &#38;#39;high&#38;#39; );
}
}

function display_meta_box() {
global $post, $meta_boxes, $key;
?&#38;gt;

&#38;lt;div class=&#38;quot;form-wrap&#38;quot;&#38;gt;

&#38;lt;?php
wp_nonce_field( plugin_basename( __FILE__ ), $key . &#38;#39;_wpnonce&#38;#39;, false, true );

foreach($meta_boxes as $meta_box) {
$data = get_post_meta($post-&#38;gt;ID, $key, true);
?&#38;gt;
&#38;lt;div class=&#38;quot;form-field form-required&#38;quot;&#38;gt;
&#38;lt;label for=&#38;quot;&#38;lt;?php echo $meta_box[ &#38;#39;name&#38;#39; ]; ?&#38;gt;&#38;quot;&#38;gt;&#38;lt;?php echo $meta_box[ &#38;#39;title&#38;#39; ]; ?&#38;gt;&#38;lt;/label&#38;gt;

&#38;lt;?php if( $meta_box[&#38;#39;type&#38;#39;] === &#38;#39;textarea&#38;#39; ) { ?&#38;gt;
  &#38;lt;textarea name=&#38;quot;&#38;lt;?php echo $meta_box[ &#38;#39;name&#38;#39; ];?&#38;gt;&#38;quot; rows=&#38;quot;4&#38;quot;&#38;gt;&#38;lt;?php echo htmlspecialchars($data[$meta_box[&#38;#39;name&#38;#39;]]); ?&#38;gt;&#38;lt;/textarea&#38;gt;
&#38;lt;?php } else { ?&#38;gt;
  &#38;lt;input type=&#38;quot;text&#38;quot; name=&#38;quot;&#38;lt;?php echo $meta_box[&#38;#39;name&#38;#39;]; ?&#38;gt;&#38;quot;
      value=&#38;quot;&#38;lt;?php echo htmlspecialchars( $data[$meta_box[&#38;#39;name&#38;#39;]]); ?&#38;gt;&#38;quot; /&#38;gt;&#38;lt;?php }?&#38;gt;
&#38;lt;p&#38;gt;&#38;lt;?php echo $meta_box[ &#38;#39;description&#38;#39; ]; ?&#38;gt;&#38;lt;/p&#38;gt;
&#38;lt;/div&#38;gt;

&#38;lt;?php } ?&#38;gt;

&#38;lt;/div&#38;gt;
&#38;lt;?php
}

function save_meta_box( $post_id ) {
global $post, $meta_boxes, $key;

foreach( $meta_boxes as $meta_box ) {
$data[ $meta_box[ &#38;#39;name&#38;#39; ] ] = $_POST[ $meta_box[ &#38;#39;name&#38;#39; ] ];
}

if ( !wp_verify_nonce( $_POST[ $key . &#38;#39;_wpnonce&#38;#39; ], plugin_basename(__FILE__) ) )
return $post_id;

if ( !current_user_can( &#38;#39;edit_post&#38;#39;, $post_id ))
return $post_id;

update_post_meta( $post_id, $key, $data );
}

add_action( &#38;#39;admin_menu&#38;#39;, &#38;#39;create_meta_box&#38;#39; );
add_action( &#38;#39;save_post&#38;#39;, &#38;#39;save_meta_box&#38;#39; );&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
