Home › Forums › Add-ons › Repeater Field › Repeater field with IF/ELSE based on sub_field value › Reply To: Repeater field with IF/ELSE based on sub_field value
Just prints the first period.. one showing.
here is the code so far
<?php
if (have_rows('row_order_and_qty')) {
while(have_rows('row_order_and_qty')){ the_row();
$post_type = get_sub_field('content_type'); echo $post_type;
$posts_per_page = get_sub_field('items_per_row'); echo $posts_per_page;
$row_query = new WP_Query(array(
'post_type' => $post_type,
'post_status' => 'publish',
'posts_per_page' => $posts_per_page,
'orderby' => 'date',
'order' => 'DESC'
));
if ($row_query->have_posts()) {
switch($post_type) {
case 'auction':
$icon = '<i class="fas fa-gavel"></i>';
$heading = 'Auctions';
$class = 'row row-cols-1 row-cols-sm-1 row-cols-md-2 row-cols-lg-4 row-cols-xl-4';
$link_url = '/auctions';
break;
case 'liquidation':
$icon = '<i class="fas fa-file-invoice-dollar"></i>';
$heading = 'Liquidations';
$class = 'row row-cols-1 row-cols-sm-1 row-cols-md-2 row-cols-lg-4 row-cols-xl-4';
$link_url = '/past-auctions';
break;
case 'inventory':
$icon = '<i class="fas fa-award">';
$heading = 'Featured Inventory';
$class = 'row row-cols-1 row-cols-sm-1 row-cols-md-2 row-cols-lg-4 row-cols-xl-4';
$link_url = '/inventory';
break;
case 'studies':
$icon = '<i class="fas fa-file-invoice"></i>';
$heading = 'Case Studies';
$class = 'row row-cols-1 row-cols-md-2 row-cols-lg-3';
$link_url = '/studies';
break;
} // end switch
?>
<h2 class="section-title mt-5"><?php echo $icon; ?> <?php echo $heading; ?> <a href="<?php echo $link_url; ?>" class="font-weight-normal text-right badge badge-primary">View All</a></h2>
<div class="<?php echo $class; ?>">
<?php
while ($row_query->have_posts()) {
$row_query->the_post(); ?>
<div class="col mb-4">
<?php // get_template_part('template-parts/card', $type); ?>
</div>
<?php
} // end while have posts
//wp_reset_postdata();
?>
</div>
<?php
} // end if have posts
} // end while have rows
} // end if have rows
?>
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.