Hi, I am making a website and believe I have encountered a rather strange bug.
I am new to ACF and am trying the free version for now before committing to developing with the paid version. The problem I have is that I do not have the repeater field and so have to do it manually.
I have set up a page for “Our Team” and so have had to set up a large number of groups for each team member each including name, position etc. 50 to be exact. I then wrote code to loop through each field and display the necessary information, and this worked fine in small scale. However, once I increased the field number to 50 members a bug occurred where member 41 does not display. I have tried moving it to different positions, remaking the field, and much more, the problems seems to be with the number 41 itself.
Here is the code I used to loop through:
<?php $team = get_field("team");?> <div class="team-strip"> <!--loop through field only displaying members(arrays) and those with a name specified--> <?php foreach ($team as $member):?> <?php if (is_array($member)):?> <?php if ($member["name"] != ""):?> <!--add class depending on category--> <?php switch ($member["category"]):?> <?php case "Administration":?> <div class="team-member administration"> <?php break; case "Boitumelo":?> <div class="team-member boitumelo"> <?php break; case "Computer Center":?> <div class="team-member computerCenter"> <?php break; case "Youth Center":?> <div class="team-member youthCenter"> <?php break; case "Counselling Center":?> <div class="team-member counsellingCenter"> <?php break; case "Performing Arts Department":?> <div class="team-member performingArtsDepartment"> <?php break; case "Urban Agriculture Initiative":?> <div class="team-member urbanAgriculture"> <?php break; default:?> <div class="team-member"> <?php endswitch;?> <!-- Display Member --> <div class="wrap"> <div class="member-photo"> <img src="<?php echo $member['photo'];?>"> </div> <div class="member-description"> <p><strong><?php echo $member["name"];?></strong></p> <p>-<?php echo $member["position"];?></p> </div> </div> </div> <?php endif;?> <?php endif;?> <?php endforeach;?> </div>
The problem is that it is returning member 41 as a string instead of an array, even though it is a group with sub-fields and is identical to all other members.
Any idea how to fix this? Thank you for your help.
When having problems with large numbers of fields you are usually running into an issue with the PHP max_input_vars setting. More information here https://www.advancedcustomfields.com/resources/limit-number-fields/
Thank you for your reply, I have tried what is suggested on the link you sent however it doesn’t seem to have fixed the problem. Also fields after the field in question still load perfectly so I do not think it is a max var issue. I even added completely new field groups on that page which all worked without hassle.
The topic ‘Field 41 Bug’ is closed to new replies.
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!