<?php
$posts = get_field('custom_ad_option', 'option');
if( $posts ): ?>
<?php foreach( $posts as $p ): // variable must NOT be called $post (IMPORTANT) ?>
<div class="single-ad"><a href="<?php the_field('link', $p->ID); ?>" target="_blank"><img src="<?php the_field('image', $p->ID); ?>" alt="<?php the_sub_field('alt_tag');?>"/></a></div>
<?php endforeach; ?>
<?php endif; ?>
Important to use the $p->ID, ex: <?php the_field('link', $p->ID); ?>
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.