<?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: Using Custom Taxonomies in Dropdown field</title>
		<link>https://legacy.forums.gravityhelp.com/topic/using-custom-taxonomies-in-dropdown-field</link>
		<description>Gravity Support Forums Topic: Using Custom Taxonomies in Dropdown field</description>
		<language>en-US</language>
		<pubDate>Thu, 23 Apr 2026 01:54:38 +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/using-custom-taxonomies-in-dropdown-field" rel="self" type="application/rss+xml" />

		<item>
			<title>Idealien on "Using Custom Taxonomies in Dropdown field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-custom-taxonomies-in-dropdown-field#post-38771</link>
			<pubDate>Mon, 24 Oct 2011 12:47:22 +0000</pubDate>
			<dc:creator>Idealien</dc:creator>
			<guid isPermaLink="false">38771@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I'll post a link here and on the &#60;a href=&#34;http://idealienstudios.com/projects/&#34; rel=&#34;nofollow&#34;&#62;Idealien projects page&#60;/a&#62; once I have finished the re-factor into a stand-alone plugin.&#60;/p&#62;
&#60;p&#62;Just have presentation layer left to work out so that the results display checks the plugin directory before the standard theme folder / template hierarchy, which is a &#60;a href=&#34;http://www.leewillis.co.uk/wordpress-custom-post-type-theming-is-broken/&#34; rel=&#34;nofollow&#34;&#62;known challenge&#60;/a&#62; to solve in a method that will play nice for all themes / etc.&#60;/p&#62;
&#60;p&#62;Right now I've got a series of shortcodes in mind that will then be able to call either from content or archive-posttype.php.&#60;/p&#62;
&#60;p&#62;J
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Using Custom Taxonomies in Dropdown field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-custom-taxonomies-in-dropdown-field#post-38741</link>
			<pubDate>Mon, 24 Oct 2011 11:46:48 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">38741@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Pretty slick.  Do you have an example form online where that's in use?  I'm sure many people would be interested in seeing it in action.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Idealien on "Using Custom Taxonomies in Dropdown field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-custom-taxonomies-in-dropdown-field#post-38672</link>
			<pubDate>Sun, 23 Oct 2011 05:08:29 +0000</pubDate>
			<dc:creator>Idealien</dc:creator>
			<guid isPermaLink="false">38672@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Found elegant solution.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_pre_render&#38;quot;, array(&#38;amp;$this, &#38;quot;populate_rideshare_type&#38;quot;));
function populate_rideshare_type($form){

    	foreach($form[&#38;#39;fields&#38;#39;] as &#38;amp;$field) {

        	if($field[&#38;#39;type&#38;#39;] != &#38;#39;post_custom_field&#38;#39; &#38;amp;&#38;amp; $field[&#38;#39;postCustomFieldName&#38;#39;] != &#38;#39;idealien_rideshare_type&#38;#39; )
            	continue;

			$rideshare_types = get_terms( &#38;#39;idealien_rideshare_type&#38;#39;, array(
 				&#38;#39;hide_empty&#38;#39; =&#38;gt; 0
 			) );

        	$choices = array(array(&#38;#39;text&#38;#39; =&#38;gt; &#38;#39;Select A Type&#38;#39;, &#38;#39;value&#38;#39; =&#38;gt; &#38;#39; &#38;#39;));

			foreach ( $rideshare_types as $type ) {
				$choices[] = array(&#38;#39;text&#38;#39; =&#38;gt; $type -&#38;gt;name, &#38;#39;value&#38;#39; =&#38;gt; $type -&#38;gt;name);
     		}

        	$field[&#38;#39;choices&#38;#39;] = $choices;

    	}

    	return $form;
	}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>Idealien on "Using Custom Taxonomies in Dropdown field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-custom-taxonomies-in-dropdown-field#post-38669</link>
			<pubDate>Sun, 23 Oct 2011 03:02:30 +0000</pubDate>
			<dc:creator>Idealien</dc:creator>
			<guid isPermaLink="false">38669@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I could use a little help with the sample code in &#60;a href=&#34;http://pastie.org/1529752&#34; rel=&#34;nofollow&#34;&#62;http://pastie.org/1529752&#60;/a&#62; - specifically the ounce_taxonomy_as_choices function and whether it might be possible to tweak this to be called via a gform_field_value_FIELDNAME for a dropdown to populate a custom taxonomy?&#60;/p&#62;
&#60;p&#62;I am &#60;a href=&#34;http://www.gravityhelp.com/forums/topic/import-on-plugin-activation-and-gf-related-plugin-advice&#34; rel=&#34;nofollow&#34;&#62;creating a plugin&#60;/a&#62; that will use GF as the submission system for a rideshare board of sorts. The plugin will create a custom post type, taxonomies and hopefully import the form upon activation. The sample you have based on gform_pre_render_## presents a challenge in that with the import I won't necessarily know the form #.&#60;/p&#62;
&#60;p&#62;Can  gform_field_value_dropdownfieldname accept array responses to populate the dropdowns? I'm using the Custom Post Types plugin which makes this selection dead simple for the standard dropdown type, but doesn't appear to support custom field dropdowns (&#60;a href=&#34;http://wordpress.org/support/topic/plugin-gravity-forms-custom-post-types-cant-get-taxonomies-to-list-out?replies=5&#34; rel=&#34;nofollow&#34;&#62;http://wordpress.org/support/topic/plugin-gravity-forms-custom-post-types-cant-get-taxonomies-to-list-out?replies=5&#60;/a&#62;)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "Using Custom Taxonomies in Dropdown field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-custom-taxonomies-in-dropdown-field#post-17714</link>
			<pubDate>Fri, 04 Feb 2011 18:30:17 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">17714@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I updated the code to correct this error: &#60;a href=&#34;http://pastie.org/1529752&#34; rel=&#34;nofollow&#34;&#62;http://pastie.org/1529752&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>jacquesbez on "Using Custom Taxonomies in Dropdown field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-custom-taxonomies-in-dropdown-field#post-17646</link>
			<pubDate>Fri, 04 Feb 2011 10:11:55 +0000</pubDate>
			<dc:creator>jacquesbez</dc:creator>
			<guid isPermaLink="false">17646@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;David &#60;/p&#62;
&#60;p&#62;I tried the script you suggested but get an error. See - &#60;a href=&#34;http://www.stayanight.co.za/test-taxonomy&#34; rel=&#34;nofollow&#34;&#62;http://www.stayanight.co.za/test-taxonomy&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;The script is:&#60;/p&#62;
&#60;p&#62;// update the &#34;18&#34; the ID of your form&#60;br /&#62;
add_action('gform_pre_render_10', 'update_gform');&#60;br /&#62;
function update_gform($form) {&#60;/p&#62;
&#60;p&#62;    // update &#34;1&#34; to the ID of your dropdown field,&#60;br /&#62;
    // update &#34;project&#34; to the slug of your taxonomy&#60;br /&#62;
    $form['fields']['1']['choices'] = ounce_posts_as_choices('type');&#60;/p&#62;
&#60;p&#62;    return $form;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;// update '18' to the ID of your form&#60;br /&#62;
add_action('gform_post_submission_10', 'process_gform', 10, 1);&#60;br /&#62;
function process_gform($entry, $form) {&#60;/p&#62;
&#60;p&#62;    // update 'project' to your taxonomy slug,&#60;br /&#62;
    // update the '13' to the to the field ID of your dropdown&#60;br /&#62;
    ounce_add_taxonomy_to_post('type', $entry['1'], $entry['post_id']);&#60;/p&#62;
&#60;p&#62;}&#60;/p&#62;
&#60;p&#62;// generate GF choices array based on taxonomy&#60;br /&#62;
function ounce_taxonomy_as_choices($taxonomy = &#34;categories&#34;) {&#60;/p&#62;
&#60;p&#62;    $taxonomy = get_terms($taxonomy, 'hide_empty=0');&#60;/p&#62;
&#60;p&#62;    $choices[0]['text'] = '';&#60;br /&#62;
    $choices[0]['value'] = '';&#60;br /&#62;
    $i = 1;&#60;br /&#62;
    foreach($taxonomy as $category) {&#60;br /&#62;
        $choices[$i]['text'] = $category-&#38;gt;name;&#60;br /&#62;
        $choices[$i]['value'] = $category-&#38;gt;name;&#60;br /&#62;
        $i++;&#60;br /&#62;
    }&#60;/p&#62;
&#60;p&#62;    return $choices;&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;// add custom taxonomy category to post&#60;br /&#62;
function ounce_add_taxonomy_to_post($taxonomy = &#34;categories&#34;, $value, $post_id) {&#60;/p&#62;
&#60;p&#62;    $categories = get_terms($taxonomy, array('hide_empty' =&#38;gt; 0));&#60;/p&#62;
&#60;p&#62;    foreach($categories as $category) {&#60;br /&#62;
        if($category-&#38;gt;name == $value) {&#60;br /&#62;
            $post = $post_id;&#60;br /&#62;
            $id = (int) $category-&#38;gt;term_id;&#60;br /&#62;
            wp_set_object_terms($post, $id, $taxonomy, TRUE);&#60;br /&#62;
        }&#60;br /&#62;
    }&#60;/p&#62;
&#60;p&#62;}
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Carl Hancock on "Using Custom Taxonomies in Dropdown field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-custom-taxonomies-in-dropdown-field#post-17611</link>
			<pubDate>Thu, 03 Feb 2011 21:40:41 +0000</pubDate>
			<dc:creator>Carl Hancock</dc:creator>
			<guid isPermaLink="false">17611@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;No, this code populates a drop down with the values of a custom taxonomy.  Not post meta/custom field data.  However, you could certainly modify this code to pull in custom field values.  In either event the code would go in your themes functions.php file.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>shshshea on "Using Custom Taxonomies in Dropdown field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-custom-taxonomies-in-dropdown-field#post-17600</link>
			<pubDate>Thu, 03 Feb 2011 18:57:40 +0000</pubDate>
			<dc:creator>shshshea</dc:creator>
			<guid isPermaLink="false">17600@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I am trying to do something similar (I think). I have a site where each blog post represents a different location. Each location offers different programs. I was hoping to create one &#34;Get More Info&#34; Gform to place within a widget section. I need the Program Drop Down menu to be populated by the content found in the Programs Custom Field box of each blog post. Hopefully that makes sense. &#60;/p&#62;
&#60;p&#62;Is that what the code linked to above is written to do? And if so, are we supposed to place it in the functions.php file?&#60;/p&#62;
&#60;p&#62;Thanks for your help.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>shshshea on "Using Custom Taxonomies in Dropdown field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-custom-taxonomies-in-dropdown-field#post-17587</link>
			<pubDate>Thu, 03 Feb 2011 16:48:51 +0000</pubDate>
			<dc:creator>shshshea</dc:creator>
			<guid isPermaLink="false">17587@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;+2
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "Using Custom Taxonomies in Dropdown field"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-custom-taxonomies-in-dropdown-field#post-17307</link>
			<pubDate>Mon, 31 Jan 2011 13:19:36 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">17307@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Jacques, I have not had an opportunity to looks at this but in the mean time here is some old code where I've done something like this before. I put some notes in here on what you will need to update to make this work with you form. Disclaimer: this has not be tested with the latest Gravity Forms and this level of customization is not covered by standard support so bear with me if you run into any issues.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://pastie.org/1515277&#34; rel=&#34;nofollow&#34;&#62;http://pastie.org/1515277&#60;/a&#62;
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
