I’m using Repeater Field and Options page add-ons.
I’m building an option panel where the user can choose the category of posts displaying in the homepage.
So, I created a repeater field with position one, position two, etc
Each position of the repeater contains a taxonomy field which extracts categories of posts and let the user choose the one preferred via select HTML.
The value which should be returned is “Term ID”.
In WP template I’d like to use the term ID as a variable for a get_posts query.
This is the code (where “priorita_homepage” is the repeater field and “prima_posizione” is a sub field)
There are 2 issue with your code that I can see:
1. You are using the_sub_field, when you should be using get_sub_field
2. Your $args are OUTSIDE the has_sub_field loop so your WP_Query or get_posts call will only happen once, not for each row in the repeater field
I finally realized that my approach was totally wrong:
– I didn’t need a repeater field, as positions are defined. Instead, for UI needs, I’ll go for the Flexible Layout Addon, the one still missing to my collection 😀
– I was missing the ‘option’ parameter between get_field brackets
Now everything is working as expected, I marked topic as resolved.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users