Alright, I managed to solve the problem by using the native get_post_meta() function.
The reason I needed this post request is a button in a form that prints a PDF of my custom post type. And after you press the button, a POST request is fired. Maybe there are better solutions but I sticked for it and didn’t want to change it.
First, I found out how many subfields there are:
$stepcount = get_post_meta($id, 'schritte')[0];
Then, I itereated:
for ($i = 0; $i < $stepcount; $i++) {
echo ($i+1).". ".get_post_meta($id, 'schritte_'.$i.'_schritt_beschreibung')[0]."<br>";
}
The most important part is the field name (schritte) and the subfields $i__schritt_beschreibung. schritt_beschreibung is the slug of the subfield.
I hope it helps
Thanks for the reply!
The $post and its ID are actually fine, I checked them. Otherwise the get_field function wouldn’t work as well.
So at first everything works, you can see the echoed ‘description_titel’ and then a few times ‘Schritt’ because of the has_sub_field-loop.
But if you press the button and the page reloads, you only see the echoed ‘description_titel’ which means that get_field works but has_sub_field doesn’t. And that really confuses me.
Let’s say we can’t make it work this way, which other possibilities do I have to get the desired fields?
P.S Maybe it is a version conflict?
ACF version: 5.6.8
WP version: 4.9.8