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.

pre-populate dropdown from title field of custom post type

  1. I have pored over previous posts on this but I get a bit lost with the hooks and query strings etc... I tried:

    query_posts( 'post_type=listing' );

    But it did not do anything. Any hints or outright instructions would be most welcome.

    Thanks

    Posted 9 years ago on Sunday February 27, 2011 | Permalink
  2. I have forwarded this forum post to one of our developers who will drop in with some information on how to use the hooks to do this. It may not be until sometime on Monday before they respond.

    Posted 9 years ago on Sunday February 27, 2011 | Permalink
  3. Hi Ekajatik,

    Paste this snippet in your functions.php file: http://pastie.org/1617402

    Make sure to update the variables as specified in the inline comments.

    Posted 9 years ago on Monday February 28, 2011 | Permalink
  4. norppa
    Member

    I think this is exactly what i need. Sorry for being a noobie but were do i get the "ID of your drop down field" and what do i need to put " $post_type = 'review'; // update"?

    Is it possible to use this approach to ask customer to chooses a product category and then populate the next dropdown menu with products from that category?

    Thanks

    Posted 9 years ago on Tuesday March 1, 2011 | Permalink
  5. Hi Norppa,

    You can retrieve your field ID by viewing the source of your form and finding the ID of the field in question. It will look something like this "input_20_4". In this example, the 20 would be the form ID and the 4 would be the field ID.

    As for the $post_type. You'll want to set this to the singular name of your desired post type. In my example I used reviews. You can replace this with any post type. Even standard WordPress post types such as "post" or "page".

    It is possible to populate one drop down with values based on the option selected in another drop down; however, to do this on the fly would require ajax and some additional coding. You can alternately use GF's built in conditional logic to make a series of hidden drop downs that only display the correct drop down based on your primary drop down selection.

    Posted 9 years ago on Tuesday March 1, 2011 | Permalink
  6. norppa
    Member

    Thanks for a quick reply. I found another thread on the forum and used the snippet from there to populate post-titles. Then i used your suggestion to use GF's built in conditional logic to hide the dropdowns. Works lika a charm, thanks guys for a great product.

    One question thou, is it possible to list entries on a page. What i mean is, a logged in user would have a page where he/she could see a list of entries they made.

    Thanks

    Posted 9 years ago on Tuesday March 1, 2011 | Permalink
  7. @norppa Gravity Forms doesn't currently list entries on the front end. But there is a plugin called the Gravity Forms Directory Add-On that is a 3rd party plugin that does do this if you wanted to try it. We didn't create it, but a lot of users are using it.

    http://wordpress.org/extend/plugins/gravity-forms-addons/

    Posted 9 years ago on Tuesday March 1, 2011 | Permalink
  8. norppa
    Member

    Could i use this to list entries on the front end?

    Thanks

    Posted 9 years ago on Wednesday March 2, 2011 | Permalink
  9. Sure, you can write custom code to list entries on the front end. Thats entirely up to you. The data is all stored in your database so it's certainly possible for you to write custom code to display it however you want.

    Posted 9 years ago on Wednesday March 2, 2011 | Permalink
  10. mourgroup
    Member

    Im using the code posted above ( http://pastie.org/1617402 ) to populate a select dropdown. But for some reason only the first 5 posts get populated. There is more than 5 posts of the specific post_type. Anyone know why this is happening?

    Posted 9 years ago on Sunday March 27, 2011 | Permalink