WordCamp Savannah, 2010

I was lucky enough to spend last weekend in Savannah, Georgia for their first WordCamp. This was the first time I’d ever been to beautiful, historic Savannah. The humidity/heat was a bit much for me, but in general I had a great time. I gave a short presentation on the new comment_form() function which is available for themes to use since 3.0. I’ve embedded my slides below, along with a link to download a PDF version.

  1. Dan said:

    How would you output the new twitter field in the comment area?
    I wanted to add a new field: "company" to the comment form and then output it below the users name
    I succeeded in adding the company input field but it doesn't show up in the comment area

    Any tips?

    Thanks in advance,

    • Beau Lebens said:

      Dan – you'd need to modify your theme to make it output the additionalinformation, and you'd also need to actually capture and store the newfield (which my examples didn't show). I don't have example code to dothat, but you'd want to look at the 'comment_post' action, triggeredduring wp_new_comment() (for saving the extra field as commentmeta)and then in your theme, you'll want a custom comment walker (see theTwenty Ten theme for an example), and call it using something likewp_list_comments( array( 'callback' => 'twentyten_comment' ) ); Inthat walker/callback, you'd use get_comment_meta() to grab the fieldyou saved and output it.

  2. Dan said:

    wow, didn't think it would be that complicated
    Thanks alot for your answer.
    Do you know of any plug-in that would achieve this?
    I thought that after actually adding the field to the form there wouldn't be much more to it


    • Beau Lebens said:

      I'm afraid I don't know of a plugin that will handle all of this for you, no. I wouldn't be surprised if one came out soon though, because the comment_form() and other parts of making this process a lot more "portable" are relatively new additions to WordPress.

    • Beau Lebens said:

      That looks like it'd do half of what you want, but it doesn't outputthe values that it stores (that's pretty much always going to requiresome sort of modification of your theme to get it to show up how youwant it).

  3. Dan said:

    Yeah, correct.
    Still, I think that a full comment plug-in including the output of the custom fields would be a great opportunity for the wordpress community.


  4. Hi Beau, how are you? Amazing post!

    I was looking on the web about ways to insert a message (just like the "set of knives giveaway) that you presented. Could you tell me what I have to modify in order to get it right? I already copied the code from the slide but where exactly to put it in the comment_form (of course I will change the msg) and which other files do I have to modify?

    You can give me the steps just like you did for yourself and I will take care of changing them to my needs.

    Thanks a lot!


    • Beau Lebens said:

      If you've copied the code, then the easiest place to drop it is probably in your theme's "functions.php" file, which is loaded on all front-end page accesses. This all assumes that your theme already calls comment_form() to render the comment form (and doesn't set up its own in HTML; you can normally look in comments.php within your theme to see this).

      If it's just a message, then slides 24 – 27 are probably a better example to use BTW.

Comments are closed.