Home Forums General Issues update_sub_field not updating images


update_sub_field not updating images

  • Hello, i have a repeater called “elements” which contains several fields, one of them is an image object. At certain point I need to update some values, and the only field that is not updating is the image field. I hope that in the code is more clear:

    if (have_rows('elements')) {
    	while ( have_rows('elements') ) : the_row();
    		$image = get_sub_field('image');
    		$image['url'] = checkUrl($image['url']);
    		update_sub_field('image', $image, $post_id);
    		$subtitle= get_sub_field('subtitle');
    		$subtitle= iterateText($subtitle);
    		update_sub_field('subtitle', $subtitle, $post_id);

    I’ve checked that the new generated url is different from the original, and it’s not getting updated. The subtitle field gets updated without any problem.

    Could you help me? Thanks!

  • The image field only holds the image attachment ID, so nothing is being updated. What is the purpost of checkURL? what does it do, and why are you trying to alter the URL of the image?

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

The topic ‘update_sub_field not updating images’ is closed to new replies.