Home Forums General Issues repeater query for specific posts


repeater query for specific posts

  • I’m making a plugin that will display my custom field type and it’s associated custom fields, but can’t figure out how to show my custom fields. I’ve repeated 3 e

    This is my relative code section:

    // kids
                $kids = get_field ('children', $post->ID); 
    	     if( $kids ) {
                    $pdf->Write(12, 'we have kids1');  //shows
                    foreach( $kids as $kid ) {
                        $pdf->Ln(10); //does NOT SHOW
    		      $pdf ->Write (12, 'a kid');  //does NOT SHOW
                        $pdf->WriteHTML( $kid['name'] ); //does NOT SHOW
    	     if( have_rows('children', $post->ID) ):
                    $pdf->Write(12, 'we have kids2'); //does NOT SHOW
    	         while ( have_rows('children', $post->ID) ) : the_row();
                        $pdf->Ln(10); //does NOT SHOW
                        $pdf->Write(12, 'a kid'); //does NOT SHOW

    This is what is being displayed:
    we have kids1

    I would expect that I would see
    we have kids1
    a kid joe
    a kid bo
    a kid duke
    we have kids2
    a kid
    a kid
    a kid

    how do I display the child subfield (name)?

  • Where are you getting the sub field values?

    I see nothing in your code to actually get a value from a sub field.

    if the field ‘children’ is a repeater then this $kids = get_field ('children', $post->ID); returns an array in the format

    $kid = array(
      {$row_index} => array(
        'sub_field_name' => 'sub_field_value'

    when using a ‘have_rows()’ loop then you need to use get_sub_field() to get the values for the row.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.