Create Dynamic Post Excerpts with Gravity Forms

This snippet allows you to create your own content template for the Post Excerpt.

Read the Walkthrough

Code

Filename: gw-dynamic-post-excerpt.php

<?php
/**
 * Gravity Wiz // Gravity Forms // Create Dynamic Post Excerpts with Gravity Forms
 * https://gravitywiz.com/create-dynamic-post-excerpts-gravity-forms/
 *
 * This snippet allows you to create your own content template for the Post Excerpt.
 */
// Update "123" to the ID of your form.
add_filter( 'gform_post_data_123', 'gw_post_excerpt_content_template', 10, 3 );
function gw_post_excerpt_content_template( $post_data, $form, $entry ) {

	// Modify this to include whatever merge tags and words you'd like included in the excerpt.
	$excerpt_template = '{Name (First):1.3} {Name (Last):1.6} tells a riveting tale about {Subject:3}.';

	$post_data['post_excerpt'] = GFCommon::replace_variables( $excerpt_template, $form, $entry );

	return $post_data;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.