Support

Account

Home Forums General Issues Get fields of each tab Reply To: Get fields of each tab

  • Thank you, John.

    Here’s my code. Maybe it’s not perfect, but it works and perhaps it will help someone else.

    <?php $tabs = acf_get_fields(27);
            for($l = 0; $l < sizeof($tabs); $l++) {
                $type = $tabs[$l]['type'];
                if($type == 'accordion') {
                    $start = $l;
                    $name = $tabs[$l]['label'];
                }
                if(($tabs[$l+1]['type'] == 'accordion') || ($l == sizeof($tabs) - 1)) {
                    $end = $l;
                    while($start <= $end) {
                        // Here you can do with the fields whatever you want
                        $start++;
                    }
            } ?> 

    Attention: I’m using the plugin Accordion Tab Field (https://de.wordpress.org/plugins/acf-accordion/) instead of the “normal” tabs. So you have to change the string ‘accordion’ to ‘tab’ for “normal” use.