I have a main field in the ACF plugin: game_list_links
which is of the repeating type.
There are 3 fields inside, the third of which is of the checkbox type: related_sub_cats
I have another main field: games_creativeplay of the repeating type
There are 2 fields inside:
Category: category_item of the text type
Subcategory: sub_category of the repeating type
I brought the subcategories into the checkbox field
sub_category => related_sub_cats
Actually, the checkbox displays the subcategories.
// Add a filter for loading ACF field values
add_filter('acf/load_field/name=related_sub_cats', function ($field) {
$games_creativeplay = get_field('games_creativeplay'); // Retrieve data from another field
if ($games_creativeplay) {
$choices = [];
// Collect all subcategories
foreach ($games_creativeplay as $category) {
if (!empty($category['sub_category'])) {
foreach ($category['sub_category'] as $sub) {
if (!empty($sub['sub_cat'])) {
$choices[$sub['sub_cat']] = $sub['sub_cat'];
}
}
}
}
// Assign choices to the field
$field['choices'] = $choices;
}
return $field;
});
On the other hand, because the number of rows in the main field game_list_links is too large, the page takes a long time to load and the page is updated after a certain number of rows, the information is not saved.
Do you have any suggestions?
I wanted to use ACF’s own pagination, but only the page that is displaying the checkbox fields is loaded and subsequent pages are not loaded.
I said maybe it is possible to create a custom pagination, but I don’t know how.
The main field pairs are in separate tabs.
Ahmad Nahvi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1