I have a custom post type with a pretty complex repeater (about 50-100 subfields per row).
My repeater have between 1 and 20 rows on each post.
Then, I created a WP_Query that retrieves posts from that custom post type, and displays them in a table (1 row of the repeater = 1 row of that table).
Everything works fine, however the query is quite slow (approx 8 seconds, and it’s only going to get worse). I am currently trying to optimize and reduce the loading time.
If I am not mistaken, when I do :
$rows = get_field(‘myrepeater’);
The query goes to fetch every subfield value in the database, whether I need it for my function or not. Correct? If yes, this is what causes most of the loading time, right?
Is there any way to prevent that?
For example, for each row, I first check if a true/false is on true. If on false, I ignore this row:
$rows = get_field('myrepeater');
foreach($rows as $row) {
$validation = $row['validation'];
if($validation != 1) {
// Do nothing
}
else {
// Get all the required fields and display them in a table row
}
}
Since I don’t need the values of the subfields of that row :
Is there a way to loop through this subfield, and only if “true” get all the subfields of the row?