Home › Forums › Add-ons › Flexible Content Field › fixable content fields value json api
Hello , I am using this code to get return value for ACF in a custom post type , but I cant seems to get the fixable content fields value
please help to update this code to add the flexible content
function wl_sportteams() {
$args = array(
'numberposts' => 99999,
'post_type' => 'sport_teams',
'orderby' => 'menu_order',
'order' => 'ASC',
'suppress_filters' => false
);
$posts = get_posts($args);
$data = [];
$i = 0;
foreach($posts as $post) {
$data[$i]['id'] = $post->ID;
$data[$i]['Team_Name'] = get_field('sport_team_name', $post->ID);
$i++;
}
return $data;
}
What to add here to get the flexible fields values please
thanks
is “sport_team_name” the name of the flex field or is this the name of one of the sub fields in a layout?
Hello
The group start like this :
Group name : Team Names
Fields :
Label : Teams | Name : Teams | type : Flexible content
then
Layout
Name : Team info | Label : team_info | Type Block
then
Fields
Label : Sport Team Name | name : sport_team_name | type : text
I hope this is clear , if not i can send you a screen shot , so basically the sport_team_name is ” a field inside a block inside flexible content ”
Thank you for you help..
You need to loop over the layouts in the flex field to get the sub field values. See example code here https://www.advancedcustomfields.com/resources/flexible-content/
yes i Have seen this , and thank you for the reply , but I have no idea how to implement it in the above script i sent , i hope you can guide me , ot edit my script just to see some example if possible thanks you
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
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.