Home › Forums › General Issues › Using unique ID/Slug in template › Reply To: Using unique ID/Slug in template
I’m assuming that you need the unique id to be in the “data-target” attribute. Whatever type of loop you’re using, create a counter and then append the counter to the class would be the simplest way to do what you want.
For example:
$count = 0;
foreach ($whatever as $thing) {
$target = 'collapse-'.$count;
?>
<div class="panel-heading" data-toggle="collapse"
data-parent="#accordion" data-target="<?php echo $target; ?>">
<?php
$count++;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.