A
A
Alexander Osadchy2020-07-02 00:04:11
WordPress
Alexander Osadchy, 2020-07-02 00:04:11

How to set a unique cheze ACF identifier for tabs?

Hello!

I have products (goods) on my site - and each has a block with tabs

.

only one taboo?

Here is a piece of code:

<ul>
            <?php while ( have_rows( 'taby' ) ) : the_row(); ?>
                <?php $field = get_sub_field_object('zagolovok_taba'); ?>
                <li data-tab="tab-<?php echo $field['key']; ?>"><a href="#"><?php the_sub_field( 'zagolovok_taba' ); ?></a></li>
            <?php endwhile; ?>
            </ul>


Wanted through get_sub_field_object('zagolovok_taba'); - but in the end, each tab has the same identifier .. how to get out? (

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Osadchiy, 2020-07-02
@DELUX

I did it .. suddenly it will help someone - here:

<ul>
            <?php while ( have_rows( 'taby' ) ) : the_row(); $i++ ?>
                <li data-tab="tab-<?php echo $i; ?>"><a href="#"><?php the_sub_field( 'zagolovok_taba' ); ?></a></li>
            <?php endwhile; ?>
            </ul>
            <?php $i = 0; ?>
            <?php while ( have_rows( 'taby' ) ) : the_row(); $i++ ?>
            <div id="tab-<?php echo $i; ?>"></div>
            <?php endwhile; ?>

I
Ivan Sedov, 2020-07-02
@ivansedov

Another option is to use get_row_index<= get_row_index(); ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question