Home Forums Front-end Issues Excerpt in a Frontend Form?


Excerpt in a Frontend Form?

  • Hi,

    Just wondering if its possible to add the post excerpt field to a frontend form with acf_form() function?

    I’ve read the sourcecode for this function but i couldn’t find a way to filter the $fields[] array.

    Is there any way to add the excerpt field somehow?


  • It doesn’t look like there is a way built into ACF, though it would be a good addition.

    It could be done, you’d need to create another fields to use for the excerpt and then create a filter, either acf/pre_save_post or acf/save_post to take the value from the field and put it into the excerpt.

    If you use the latter (acf/save_post) be careful of creating a save post infinite loop.

    add_action('acf/save_post', 'my_save_post_filter', 20);
    function my_save_post_filter($post_id) {
      if (get_post_type($post_id) != 'your-post-type')) {
      // remove this filter to avoid infinite loop
      remove_filter('acf/save_post', 'my_save_post_filter', 20);
      // get your value and update post
      // see
      // put this filter back in place
      add_action('acf/save_post', 'my_save_post_filter', 20);
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Excerpt in a Frontend Form?’ is closed to new replies.