Support

Account

Home Forums ACF PRO Frontend Post Excerpt Field With acf_form()

Solved

Frontend Post Excerpt Field With acf_form()

  • Hi there,

    I’m using acf_form() on the front end to add AND edit a custom post type. I want this to be an ACF field as opposed to an acf_form() arguement so that I can have more control. The only thing is that I’m having a difficult time figuring out how to have an ACF WYSIWG field:

    1. populate the data from post_excerpt
      – and –
    2. obviously save said post_exerpt.

    I’ve looked at both acf/save_post and the forum topic, ‘Excerpt in a Frontend Form?‘ as well as the forum topic, ‘Field to write into the_content & the_excerpt‘ …but I’m still at a loss as to how this would be accomplished…it looks like people got started, but weren’t able to post a concrete solution.

    I’m guessing this would use both acf/save_post and / or acf/pre_save_post but, I’m not sure how exactly. Maybe it’s me, but it sort of seems like mapping fields to edit the title/excerpt/content would be a bit more intuitive/easy, so hopefully someone has an idea/solution on this because I’d imagine it’s a quite common problem.

    Thanks a bunch in advance!

    Does anyone know how this might be accomplished?

    Thanks!

  • Well, I guess I figured it out. However, would doing this even be advisable?

    I ask because… if we’re be able to manage the post_excerpt via acf/save_post with a custom ACF WYSIWG field, wouldn’t it just bloat the database? I.e. have a value stored for both the ACF and post_excerpt field?

    The code I’ve used:

    function update_post_excerpt($post_id) {
    
    	// Set excerpt value from field
    	$post_excerpt = get_field('field_12345',$post_id);
    	
    	// Update post options array
    	$update_post_excerpt_args = array(
    		'ID'			=> $post_id,
    		'post_excerpt'	=> $post_excerpt,
    	);
    	
    	// Update the post into the database
    	wp_update_post( $update_post_excerpt_args );
    }
    
    add_action('acf/save_post', 'update_post_excerpt', 20);
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Frontend Post Excerpt Field With acf_form()’ is closed to new replies.