I am using the Wordpress plugin advanced custom fields. I am using the following to call in a Repeater Group on a page:
<?php
$rows = get_field('machine_downloads');
if($rows){ ?>
<?php foreach($rows as $row){ ?>
<?php if($row['machine_downloads_file']){ ?>
<a href="<?php echo $row['machine_downloads_file']; ?>" class="btn grey">+ Download PDF</a>
<?php } ?>
<?php } ?>
<?php } ?>
I would like to use the same Repeater Group on another page, but limit it to only display the first item in the Repeater group. Any one able to help?
thanks Martin
Why not just access the first 'machine_downloads_file'
directly? Get rid of the foreach
:
<?php
$rows = get_field("machine_downloads");
if($rows[0]['machine_downloads_file']){
echo '<a href="' . $rows[0]["machine_downloads_file"] . '" class="btn grey">+ Download PDF</a>';
}
?>