Support

Account

Home Forums Backend Issues (wp-admin) Add ACF Field to Featured Image Meta Box

Helping

Add ACF Field to Featured Image Meta Box

  • I’m trying to append a Featured Video field group to the existing Featured Image meta box. I created the field group and set the Active status to false so that it won’t render. I then added the following function to render the acf_form in the Featured Image meta box:

    add_filter ( 'admin_post_thumbnail_html', function ( $content, $post_id ) {
    	ob_start();
    	acf_form ( array (
    		'post_id' => $post_id,
    		'field_groups' => array (
    			'group_5c8692ea50b96'
    		),
    		'form' => false,
    		'field_el' => false,
    	) );
    	$content .= ob_get_contents();
    	ob_end_clean();
    	return $content;
    }, 10, 2 );

    This does render the field group to the meta box, and it also passes the data along with the form submission… but it doesn’t save the meta value to the post. I’m assuming that I need to tell WordPress to look for that form field and update the meta accordingly, I’m just not sure exactly where to do that.

    Any ideas?

  • There are too many things that could be causing the values not to be saved correctly.

    1) acf_form() event when used in the admin, requires that acf_form_head() is called.
    2) values submitted using acf_form() are usually processed differently then how acf normally does this for admin submission.
    3) unknowns

    Why not use acf to hide the “feature image” meta box and create your own using an ACF field group?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.