Support

Account

Home Forums General Issues ACF Repeater: No posts

Solved

ACF Repeater: No posts

  • ACF PRO: 5.3.7

    I’m using ACF Repeater to create a series of Sub Fields and wish to post them in a table layout, but the content is not posting:

    <!--PARTS content display in table--> 
    <?php if( get_field('partsno') ): ?>
            <div role="tabpanel" class="tab-pane fade" id="specifications">
    			<div class="container">
                <?php
                    // vars
    				$rows = get_field('partsno');
                                    $heading = get_sub_field('heading');
    				$partno = get_sub_field('part_no');
    				$modelno = get_sub_field('model_no'); 
    				$diameter = get_sub_field('dia');
    				$hp = get_sub_field('hp');
    				$cfm = get_sub_field('cfm');
    				$dimensions = get_sub_field('dimensions_w_x_d_x_h');
    				$weight = get_sub_field('weight');
            ?>
                 
                <?php if( have_rows('partsno') ): ?>
    			 <table class="table table-striped" border="0">
    			 <tbody>
                 <tr>
    					<th scope="row">&nbsp;</th>
    					<td>Part No.</td>
                        <td>Model No.</td>
                        <td>Dia.</td>
                        <td>HP</td>
                        <td>CFM</td>
                        <td>Dimensions (W" x D" x H")</td>
                        <td>Weight</td>
    				
    				</tr>
    
    	         <?php while( have_rows('partsno') ): the_row(); ?>
    		
    				<tr>
    					<td><?php the_sub_field('heading'); ?></td>
    					<td><?php the_sub_field('part_no'); ?></td>
                        <td><?php the_sub_field('model_no'); ?></td>
                        <td><?php the_sub_field('dia'); ?></td>
                        <td><?php the_sub_field('hp'); ?></td>
                        <td><?php the_sub_field('cfm'); ?></td>
                        <td><?php the_sub_field('dimensions_w_x_d_x_h'); ?></td>
                        <td><?php the_sub_field('weight'); ?></td>
    				
    				</tr>
                <?php endwhile; ?>
                
    			</tbody>
                </table>
            
        	    <?php endif; ?>
                
           		</div><!--end container-->
                 
    		</div><!-- end tabpanel-->
    
    <?php endif; ?><!--end PARTS if-->

    The Field Name is as above and all of the Sub Fields match to the above.

  • Hi @toad78

    Your code looks great for me. Did you put it outside of The Loop? If you did, you need to pass the post ID as the second parameter of the have_rows() function. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/have_rows/. So, it should be something like this:

    <?php if( have_rows('partsno', '99') ): ?>
        <?php while( have_rows('partsno', '99') ): the_row(); ?>

    Where ’99’ is the ID of the post that has the repeater field.

    If it doesn’t work, could you please share the JSON or XML export of the field group and the complete PHP template file where you put that code?

    Thanks!

  • I don’t think I put it outside the loop. How would I share the JSON or XML export of the field group?

    The complete template is attached.

  • Hi @toad78

    You can get the export file from “Custom Fields > Tools” (PRO version) or “Custom Fields > Export” (free version).

    Also, it seems that the forum doesn’t allow you to attach a PHP file. Could you please zip it first?

    Thanks 🙂

  • Here you are.

  • Hi @toad78

    I’ve just tested the import file and it was working correctly on my end. It seems that you use the custom fields for WooCommerce product page. Did you add the code in the right template file? I tried it in “single-product.php” template file and the table was showing up. Could you please test it up?

    Thanks!

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

The topic ‘ACF Repeater: No posts’ is closed to new replies.