
Hello
I have a site that is displaying a list of books in categories.
I am using a repeater field for the categories and within that another repeater field for the list of books -each book has title, summary, image and link.
The first category is always ‘Current Read’ which has 1 book in it.
When there is a new current read, I have to delete that book and add it to one of the other categories.
Ideally I would add a book to a category, if it is the current read there would be a checkbox in the nested repeater which would enable me to display that book before the loop.
I suspect this isn’t going to be possible.
Can anyone please help?
Here is the code at the moment:
<?php if( have_rows('book_recommendations') ): ?>
<div id="bookreclist">
<?php
// loop through rows (parent repeater)
while( have_rows('book_recommendations') ): the_row(); ?>
<div class="bookreccat">
<h2><?php the_sub_field('rec_category_title'); ?></h2>
<?php
/////// Book Recommendations
// check for rows (sub repeater)
if( have_rows('book_rec_list') ): ?>
<ul>
<?php // loop through rows (sub repeater)
while( have_rows('book_rec_list') ): the_row();?>
<li><a href="<?php the_sub_field('book_rec_link'); ?>" target="_blank"><img src="<?php the_sub_field('book_rec_image'); ?>" alt="<?php the_sub_field('book_rec_title'); ?>" /></a>
<h3><a href="<?php the_sub_field('book_rec_link'); ?>" target="_blank"><?php the_sub_field('book_rec_title'); ?></a></h3>
<?php the_sub_field('book_rec_summary'); ?>
</li>
<?php endwhile; ?>
</ul>
<?php endif; //if( get_sub_field('book_rec_list') ): ?>
</div> <!-- .booklistcat -->
<?php endwhile;?>