Support

Account

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++;
    }