Support

Account

Home Forums Add-ons Repeater Field Looping custom post content using a taxonomy field in a repeater field

Unread

Looping custom post content using a taxonomy field in a repeater field

  • Hi

    I’ve got a repeater field that I’m using to create multiple sections on a page. The repeater fields will control the title and content of a given field and the WP category that relates to it. The goal is the then call custom posts in that category to the section to display.

    The loop that I’ve written for the repeater works and the array I’ve written for the posts works. But I can’t work out how to take the taxonomy result from the repeater and use that to determine what is outputted from the custom posts array.

    Much googling and forum searching hasn’t turned up exactly what I’m looking for and I’m looking for help or advice to solve it.

    Source code below.

    Thanks in advance

        <?php if( have_rows('theme_info') ): ?>
        
        <?php while( have_rows('theme_info') ): the_row(); 
            $title = get_sub_field('theme_title');
            $id = get_sub_field('section_id');
            $cat = get_sub_field('theme_category');
            $themecontent = get_sub_field('theme_content');
            ?>
    
    <div class="individual-theme-wrapper">
                
                <div class="theme-intro">
    
                <a class="anchor" id="<?php the_sub_field('section_id'); ?>"></a>
                    <p class="h1"><?php the_sub_field('theme_title'); ?></p>
                    <?php the_sub_field('theme_content'); ?>
    
                </div>
    
                <div class="theme-speakers">
    
                
                  <?php 
                    $projects = new WP_Query([
                      'post_type' => 'bes_speakers',
                      'posts_per_page' => -1,
                      // 'cat' => ,
                      'order_by' => 'date',
                      'order' => 'asc',
                    ]);
                  ?>
    
                  <?php if($projects->have_posts()): ?>
                    <div class="bes-speakers">
                      <?php
                        while($projects->have_posts()) : $projects->the_post();
                          include('partials/bes-speaker-tile.php');
                        endwhile;
                      ?>
                    </div>
    
                    <?php wp_reset_postdata(); ?>
                  <?php endif; ?>
    
                </div>
    
            </div>
    
        <?php endwhile; ?>
        
    <?php endif; ?>
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.