So, I’m seeing how to use the query loop for CPT’s, but I’m drawing a blank on how to do this with just ACF fields. Do I need to just make a CPT, and give the ACF fields to that and my page just so its associated?
I have repeater fields as well and I saw those aren’t supported yet, so I’ll fumble through the ACF docs to see if I can get the code right.
Any feedback however on the 1st question would be great.
Do you have an example where you only use ACF fields? From my understanding ACF fields are always associated with something else like a post type (that you set in Location - Rules in ACF). So like you said, making a CPT and just using that association would then make it possible to make a query loop for your ACF fields.
Well, example would be a restaurant menu thats on a ‘page’. ACF fields configured to show just on the page so the customer can just update the fields without touching editing the page itself. This particular case involves a repeater field, but I can use code for that, but the query loop, I couldn’t figure out how to target just the ACF fields in the page.
Thanks for the clarification, I think I understand your question better now. From what I know you can’t create a query loop for a custom field like that atm. That would be a great feature to have imo. I hope I’m wrong though and someone else can shine more light on a possible solution to use query loops for that purpose.
Hi Lyle,
Correct, the repeater is currently not supported. The only way to loop over your repeater fields is custom code within a code block. The ACF documentation provides you with some perfect examples you can use almost out of the box. Of course, you’ll need custom CSS to style the output.
Another way would be a custom post type called “menu”. You can add each menu item as an individual post, add ACF fields for the price, for example, and output the menu items on the menu page with the query loop.
Yea, the 1st option was the way I wanted to go as its the least amount of backend work and makes more sense from a menu standpoint.
The latter method is just way to much from a maintenance standpoint and ease of use for a end customer. THe latter actually could be done with a repeater as well and use the q-loop for the items with a codeblock as well, no? If I do it that way, and query over a single CPT post, and within that have repeater fields, then use the codeblock to extract that, would that work?