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.

Mapping Fields Content to Post Template

  1. Hello, I am trying to understand how to get the contents of fields submitted to a form into an existing post template. Here's an example of the code. Can you tell me what code I would need to insert to extract the field contents to this template?
    <?php get_header(); ?>

    <div class="grid_8" >
    <div id="left_content">
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post();$do_not_duplicate = $post->ID; ?>
    <!-- Property Details -->
    <div class="listing-meta-top">
    <h1>
    <?php the_title();?>
    |</div>
    <div class="single-address">
    <?php _e ("Location: ","language"); ?>
    <?php $gvw2 = get_post_meta($post->ID, 'city', true);
    if ( $gvw2 ) { echo $gvw2 ; } else { echo ''; } ?>
    ,
    <?php $gvw3 = get_post_meta($post->ID, 'state', true); if ( $gvw3 ) { echo $gvw3; } else { echo ''; } ?>
    </br>
    <?php _e("Have Music Will Travel: ","language"); ?>
    <?php $gvw19 = get_post_meta($post->ID, 'travel', true);
    if ( $gvw19 ) { echo $gvw19 ; } else { echo ''; } ?>
    </br>
    <?php _e("Pay Range: ","language"); ?>
    <?php $gvw20 = get_post_meta($post->ID, 'fee', true);
    if ( $gvw20 ) { echo $gvw20 ; } else { echo ''; } ?>
    </div>

    Posted 7 years ago on Friday June 17, 2011 | Permalink
  2. I don't understand what you are trying to do. I'm not sure what you mean by extract fields into a post template or how this relates to Gravity Forms.

    Posted 7 years ago on Friday June 17, 2011 | Permalink
  3. I want to have the content of the fields submitted by the user populate a custom post template - the code shown is that custom template.

    Posted 7 years ago on Friday June 17, 2011 | Permalink
  4. If you want Gravity Forms to create a Post then you need to configure your form to create a WordPress Post using the Post Fields. Post fields are the only thing in Gravity Forms that create WordPress Posts.

    Other than that i'm not really sure what you are asking. Gravity Forms can create Posts, and how you display those Posts is up to you and your theme. All Gravity Forms does is create the Post, it doesn't display the Post on the frontend. That is up to your theme.

    Posted 7 years ago on Friday June 17, 2011 | Permalink
  5. I have tried this and a post was created with the Title field as the name of the post. Now I just need to get the other fields into the post along with the title.

    Posted 7 years ago on Friday June 17, 2011 | Permalink
  6. Nothing needs to go into the content editor (fckeditor)

    Posted 7 years ago on Friday June 17, 2011 | Permalink
  7. If by "other" fields you mean Custom Fields, which any content fields other than the Title and Body are going to be, you need to use the Custom Field under the Post Fields. You then need to configure the Custom Field so it uses the Custom Field Name of an existing Custom Field or you can create a new one. This custom field name is what your post template is trying to display when it calls the post meta. So you have to use Custom Fields.

    Posted 7 years ago on Friday June 17, 2011 | Permalink
  8. Here's a thread that explains this pretty well:
    http://www.gravityhelp.com/forums/topic/post-fields-not-working

    Posted 7 years ago on Monday June 20, 2011 | Permalink
  9. @adhoc Yes, that thread also had the solution. The user in that thread wasn't using the Post Body field which is why no body was being created, just a title when the post was created. They added a Post Body field to their form and that corrected the issue. If certain data isn't being created in your Post it's because your form is missing the necessary fields to create that data or you are using the wrong field type. Only fields under Post Fields in the form editor create post data.

    Posted 7 years ago on Monday June 20, 2011 | Permalink