I used this plugin
https://wordpress.org/plugins/insert-php/#description
and also tried this code

[insert_php]

$custom_fields = get_post_custom(1069);

$add_products = $custom_fields['add_products'];

print_r($add_products);

output:

Array ( [0] => 5 )

but still when I use for loop or foreach loop then code is not working

$custom_fields = get_post_custom(1069);

$add_products = $custom_fields['add_products'];

for ($i=0; $i < 4; $i++)
{

echo $imageurl = do_shortcode('[acf field="add_products_'.$i.'_add_image" post_id="1069"]');


}

$colorvalue = do_shortcode('[acf field="add_products_1_image" 
post_id="1069"]');

print_r($colorvalue);

output:

(BLANK)

Read more here: "for" loop not works in inbuilt wordpress plugin, why for loop not works in [insert-php]


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: