Support

Account

Forum Replies Created

  • Oh, of course $content means $my_content, but that’s not the reason.

  • Thank you!

    I tried this, but it failed:

    function my_save_post( $post_id ) {
    	$my_content = get_field('post_content', $post_id);
    	if($my_content){
    	preg_match_all('/wp-image-(\d+)/', $content, $matches);
    	$imagatt = $matches[1];
    		foreach( $imagatt as $imagat ):
    			$post_to_update = array(
    				'ID'           => $imagat,
    				'post_parent'  => $post_id
    			);
    			wp_update_post( $post_to_update );
    		endforeach;
    	}
    }
    add_action('acf/save_post', 'my_save_post', 20);

    I also tried
    $my_content = $_POST['post_content'];
    instead of
    $my_content = get_field('post_content', $post_id);

    In template I use:

    <?php acf_form(array(
            'post_id'       => 'new_post',
            'new_post'      => array(
             'post_type'     => 'upr',
            ),
    	'post_title'    => true,
            'post_content'  => true,
            'submit_value'  => 'Add item'
        )); ?>

    Can you help me? I think the solution is not so far…

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