PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, January 22, 2022

[FIXED] Advanced Custom Fields : Repeaters

 January 22, 2022     acfpro, advanced-custom-fields, php, wordpress     No comments   

Issue

I'm trying to display below using ACF

(There are multiple sections so made this section a repeater) - Section Title ( Under section title there are multiple packages so made this section a repeater as well) -- Package Title -- Price

Everytime when I'm add a section it should display as a new section underneath the previouse section. Instead of that it showing inside of previouse section.

Can you please point me what I'm doing wrong here.

<div class="pricing">
            <?php
                if(have_rows('packages')): 
                    while(have_rows('packages')) : the_row();?>
                <div class="pricing-section">        
                <?php  echo the_sub_field('section_title_and_details'); ?>
                </div>
                
                <div class="pricing-package-container">        
                    <?php if(have_rows('package_details')): 
                                while(have_rows('package_details')) : the_row(); ?>
                    <div class="pricing-packages">
                                <h3><?php echo the_sub_field('package_name'); ?></h3>
                                <h4><?php echo the_sub_field('price'); ?></h4>
                    </div>
                            <?php endwhile;
                        endif;
                    endwhile;
                endif;
                ?>
                </div>
        </div>

Solution

As @HowardE Pointed out above, pricing-package-container was closing outside of the loop. Fixed it as below.

<!-- Custom Feilds -->
        <div class="pricing">
            <?php
                if(have_rows('packages')): 
                    while(have_rows('packages')) : the_row();?>
                <div class="pricing-section">        
                <?php the_sub_field('section_title_and_details'); ?>
                </div>
                
                    <div class="pricing-package-container">        
                    <?php if(have_rows('package_details')): 
                                while(have_rows('package_details')) : the_row(); ?>
                    <div class="pricing-packages">
                                <h3><?php the_sub_field('package_name'); ?></h3>
                                <h4><?php the_sub_field('price'); ?></h4>
                    </div>
                            <?php endwhile;
                        endif; ?>
                    </div>
                   <?php endwhile;
                endif;
                ?>
        </div>
       


Answered By - Asanka
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing