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.

Pull-down Field populated from post titles

  1. Hi Guys,

    I just read this thread http://www.gravityhelp.com/forums/topic/automatically-populate-a-dropdown-with-post-titles" and have made a lot of progress but I seem to have an issue with the results.

    I tweaked the form number and the field ID - but the results are only 5 posts (the most recent posts) and not in the correct category. Do I need to use the category name or the slug (I tried the slug - no joy)? Also, I can't figure out why only 5 posts are showing...I don't see a limit set in the code.

    What I want to do:
    I have a dog rescue site where we list Available Beagles, one per post. We allow readers to sponsor beagles and I have set up the sponsorship page with a form where they can select which dog they want to sponsor from the list of available beagles in that category.

    You can get to the site: newtest.brewbeagles.org. You'll see both the the Sponsor a Beagle page and the Available Beagles list there.

    I know very little about .php, and I've gotten this far mostly because your instructions on that earlier thread were AMA-ZING!

    Can you help me?
    Laura

    Posted 14 years ago on Saturday April 16, 2011 | Permalink
  2. Hi Laura,

    Give this updated snippet a shot:

    http://pastie.org/1804905

    You'll want to update the form ID, the drop down field ID, and the category ID where specified in the code. Let me know if you have any questions.

    Posted 14 years ago on Sunday April 17, 2011 | Permalink
  3. Hi.

    Unfortunately, now I'm getting this error:

    Parse error: syntax error, unexpected $end in /home/brewbe2/public_html/newtest/wp-content/themes/ultrawebstudio/functions.php on line 345

    And I can't get in to my website, front-end or back-end.

    Laura

    Posted 14 years ago on Sunday April 17, 2011 | Permalink
  4. Hi Laura,

    You probably left the "<?php" opening tag from the snippet in your code where a "<?php" opening tag was already open. Just remove this tag from the line in error.

    I did not realize you were adding this code from within the WP editor to your functions.php file. This is not advisable due to this current situation. If you make any mistakes, you can not undo them since the site (front end and back end) will be inaccessible.

    You will want to login via FTP, open your theme's functions.php file and remove the "<?php" tag at the line indicated by the PHP error. Sorry for the confusion.

    Posted 14 years ago on Sunday April 17, 2011 | Permalink
  5. David,

    No worries. I did a restore from last night so my site is back up. I'll try it again shortly.

    And yes, I did make the change from the wp admin site...something I won't do again.

    I'm not very good at php which is what led to that error.

    Laura

    Posted 14 years ago on Sunday April 17, 2011 | Permalink
  6. David,

    Can we talk offline? I added it back in and got a similar error message. I'd like to get your help if you're willing to assist.

    Laura

    Posted 14 years ago on Sunday April 17, 2011 | Permalink
  7. Hi Laura,

    Shoot me an email at david@rocketgenius.com with an FTP and WP Admin login and I will take a look. :)

    Posted 14 years ago on Monday April 18, 2011 | Permalink
  8. jrosebud
    Member

    I just wanted to say that I had the same problem but was able to fix it by changing this line in code:

    $posts = get_posts("category=Business");

    to

    $posts = get_posts("category=Business&posts_per_page=-1");

    Obviously, you'd change the category to your category or custom post type or taxonomy or whatever you're trying to populate your dropdown with.

    Posted 14 years ago on Friday August 26, 2011 | Permalink