Support

Account

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