Home › Forums › General Issues › has_sub_field won't work after POST request › Reply To: has_sub_field won't work after POST request
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
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.