![]() ![]() ![]() Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Shipping Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. A counter is also useless for the same reason- the title and content will have the same iteration count as they are in the same row. Since both the title and content are together in the same row, it is impossible to check when they are both queried. The reason you would use two of the same loops to output the data is because there isn’t an obvious way to separate the data in each row into different wrappers without restarting the loop over again.Īs I quickly found out, conditionals are useless in this scenario. Copy that same loop to get each row’s tab content, and build the tabs. ![]() Write a loop in the page template to iterate through the repeater field, grab the title fields, and build the navigation.Create a custom repeater field with ACF, with each row containing a title and content.Naturally, after running into this problem many times over working on various different sites, I just had to ask, isn’t there a better way to display all this content iteratively using just one loop instead of having to repeat myself?!Īs a real world example, today I had to create a page layout similar to Bootstrap’s javascript tabs.Ī standard workflow might look like this: I often run into this issue when I am building things like accordions, or tabbed data in WordPress. When you’re iterating over arrays in PHP and wanting to display the returned data into different wrappers, it can get messy pretty quickly, especially when HTML markup is thrown into the mix. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |