Create Dynamic Post Excerpts with Gravity Forms

Gravity Forms provides an awesome option to create a “Content Template” for the Post Title and Post Body fields; however, the lowly Post Excerpt feel does not have this option.

Here’s a quick snippet which allows you to create your own content template for the Post Excerpt of any post created by a Gravity Form.


  1. Jeff Turner
    Jeff Turner February 16, 2017 at 10:51 pm

    Is there a way to add html or css in the excerpt template….trying to replicate the way a byline looks in the content section (using the built in content template available in the content field) Just need to increase text size and/or color for “by {merge code first name} {merge code last name}, {merge code position}, then just leave {merge code body copy} as normal text?

  2. Jake
    Jake December 16, 2016 at 7:09 am

    Hi David,

    This is fantastic – thank you for this bit of code. It would be great if $excerpt_template picked up field values instead of field labels.

    1. David Smith
      David Smith Staff December 19, 2016 at 9:06 pm

      Are you using a choice-based field? If so, you can use the “:value” modifier. Example: {My Field:1:value}.

  3. Sunit
    Sunit December 16, 2016 at 12:48 am

    Hi David,

    Will the snippet also work for custom post type, say the product short description of a Woocommerce product using your plugin Gravity Forms + Custom Post Types?

  4. Brett
    Brett July 17, 2016 at 12:30 pm

    I am using this, and it is working great… however I have not found a way to include a line break in the post excerpt.

    Any suggestions?

    1. David Smith
      David Smith Staff August 8, 2016 at 12:30 pm

      I tested with Twenty Sixteen and line breaks in the Post Excerpt worked as expected. Sounds like it may be a theme issue.

    1. David Smith
      David Smith Staff March 14, 2016 at 8:27 pm

      Hi Grace, 10 is the priority that our function should be run in compared to all other functions bound to this same action. 3 refers to the number of parameters that should be passed to our function. This is limited by the number of parameters specified wherever the action/filter is called in the source code.

  5. Lauren
    Lauren February 5, 2015 at 7:10 pm

    Hey David!

    I’m SO excited to find this snippet, as I’ve been searching for a way to use merge tags in excerpts. I put this snippet in the functions.php file and changed the ID to the ID of my form, but nothing seems to have changed. Where should I insert this snippet?

    Thank you for all your great work!


    1. David Smith
      David Smith Staff February 6, 2015 at 7:05 am

      Hi Lauren, can you confirm this was placed in your theme’s functions.php file? I’ve seen some folks accidentally put this in */wp-includes/functions.php** which won’t work. If you’re sure you put it in the right file, could you send me a URL to your form and a pastie with the contents of your functions.php file?

  6. Gil Namur
    Gil Namur January 27, 2015 at 11:23 pm

    Hi David,

    This works perfectly. Thank you so much for this!

    I also want to take a moment to let any of your readers know that you have been an excellent resource to me recently.

    I recently had you do some work for me and your approach was very professional and your communications were succinct, timely and courteous. You are a breath of fresh air.

    Let the reader understand that I would never hesitate to use David for any GF coding that I need and encourage you to do likewise. You will not be disappointed!

    Thanks again David!


    Gil Namur President & CEO Life As A Human Inc.


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.