PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Dyanimacally populating drop down with custom field values of posts

  1. This post in the "How-To" Documentation has helped me a ton!
    http://www.gravityhelp.com/documentation/page/Dynamically_Populating_Drop_Down_Fields
    I first want to say thanks for this info!!

    In this example how to it was described how to populate a drop down with the post_title of custom post types dynamically.

    I know have an instance where I would like to dynamically populate a drop down field with the a custom field value of the post rather than the post_title of that post.

    Here is the full code from the "How-To" doc
    http://pastie.org/2105544

    Can anyone help me out?
    Thanks!

    Posted 12 years ago on Tuesday November 29, 2011 | Permalink
  2. Hi Fallingup,

    You can do this by replacing line 20 of the pasted snippet to this:

    [php]
    $choices[] = array('text' => get_post_meta($post->ID, 'meta_key', true), 'value' => get_post_meta($post->ID, 'meta_key', true));

    Replace "meta_key" with the meta key of the custom field you are trying to retrieve.

    Posted 12 years ago on Tuesday November 29, 2011 | Permalink
  3. You are the best! Thanks so much David :) Works like a charm!

    Posted 12 years ago on Tuesday November 29, 2011 | Permalink
  4. David has also updated the tutorial to include this information in the tutorial here:

    http://www.gravityhelp.com/documentation/page/Dynamically_Populating_Drop_Down_Fields

    Posted 12 years ago on Tuesday November 29, 2011 | Permalink

This topic has been resolved and has been closed to new replies.