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.

Use Gravity Forms Shortcode in a Custom Field...

  1. I thought I would share this. I have a template that uses custom fields to output content in an additional content area on the page. I had been outputting the content in the template using this code:

    echo wpautop(get_post_meta($post->ID, 'custom_field_name_here', true));

    This outputted the content with the shortcode as text (not being processed). I changed it to the following and was able to allow users to use shortcodes in the custom field and have the shortcode output the form on the page properly.

    echo apply_filters('the_content', get_post_meta($post->ID, 'custom_field_name_here', true));

    Be sure to replace custom_field_name_here with your custom field name. This code goes in a template file of your theme. You will also need to include the gravity form CSS file explicitly as it does not seem to get inserted automatically using this method. I added this to the top of my template file.

    <link rel='stylesheet' id='gforms_css-css' href='/wp-content/plugins/gravityforms/css/forms.css?ver=2.9.2' type='text/css' media='' />

    Hope this helps others.

    Posted 13 years ago on Wednesday June 9, 2010 | Permalink
  2. When I do this I get a JS error...

    Error: gf_apply_rules is not defined

    Any ideas?

    Posted 13 years ago on Wednesday September 15, 2010 | Permalink