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.
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.