0

カスタム分類テンプレートにリピーター フィールドを含めようとしていますが、表示する投稿が返されません。表示する投稿があることを知っているので、困惑しています。
追加しようとしましwp_reset_postdata()たが、何もしませんでした。エラーは発生していません。

問題のリピーターは次のとおりです。

        <?php if( have_rows('feature_repeater') ): ?>
 <div class="related-posts">
        <h2>You May Also Like...</h2>
    <div>

    <?php while( have_rows('feature_repeater') ): the_row(); 

        // vars
        $image = get_sub_field('collection_image');
        $content = get_sub_field('collection_title');
        $link = get_sub_field('collection_link');

        ?>

        <div>

            <?php if( $link ): ?>
                <a href="<?php echo $link; ?>">
            <?php endif; ?>

                <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />

            <?php if( $link ): ?>
                </a>
            <?php endif; ?>

            <?php echo $content; ?>

        </div>

    <?php endwhile; ?>


        </div>
</div>
<?php else : ?>

       No Posts to Display

<?php endif; ?>



ここに私のテンプレートがあります:

<?php
/**
 * Template used for single posts and other post-types
 * that don't have a specific template.
 *
 * @package Avada
 * @subpackage Templates
 */

// Do not allow directly accessing this file.
if ( ! defined( 'ABSPATH' ) ) {
    exit( 'Direct script access denied.' );
}

?>
<?php get_header(); ?>

<section id="content" class="full-width" style="width: 100%;">

            <div id="post-15912" class="fusion-archive-description post-15912 avada_portfolio type-avada_portfolio status-publish format-standard has-post-thumbnail hentry portfolio_category-dumfries-and-galloway inn-features-coastal-breaks inn-features-countryside-walks inn-features-cycling-holidays inn-features-dog-friendly-pubs inn-features-fine-dining inn-features-fishing-holidays inn-features-romantic-getaways">
                <div class="post-content">
                    <?php
                    $portfolio_cat_slug = get_queried_object()->slug;
                    $portfolio_cat_name = get_queried_object()->name;
                    ?>
                    <h1><?php echo $portfolio_cat_name; ?></h1>
                    <?php echo category_description(); ?>

                    <div class="fusion-aligncenter" style="margin-top: 20px;"><a href="<?php get_site_url(); ?>/gift-vouchers/" class="fusion-button button-flat fusion-button-default-size button-default button-1 fusion-button-default-span fusion-button-default-type" style="margin-bottom: 20px;">Buy <?php echo $portfolio_cat_name; ?> Gift Vouchers</a></div> 

                </div>   
               <div class="fusion-posts-container fusion-blog-layout-grid fusion-blog-layout-grid-3 isotope fusion-blog-pagination " data-pages="2" style="position: relative; height: 1384.4px;">
            <?php
                $collection_post_args = array(
                    'post_type' => 'avada_portfolio', // Your Post type Name that You Registered
                    'posts_per_page' => 999,
                    'order' => 'DESC',
                    'tax_query' => array(
                        array(
                            'taxonomy' => 'inn-features',
                            'field' => 'slug',
                            'terms' => $portfolio_cat_slug
                        )
                    )
                );
                $collection_post_qry = new WP_Query($collection_post_args);

                if($collection_post_qry->have_posts()) :
                   while($collection_post_qry->have_posts()) :
                        $collection_post_qry->the_post(); 
            ?>
                   <article id="post-15912" class="fusion-post-grid  post fusion-clearfix post-15912 avada_portfolio type-avada_portfolio status-publish format-standard has-post-thumbnail hentry portfolio_category-dumfries-and-galloway inn-features-coastal-breaks inn-features-countryside-walks inn-features-cycling-holidays inn-features-dog-friendly-pubs inn-features-fine-dining inn-features-fishing-holidays inn-features-romantic-getaways" style="position: absolute; left: 0px; top: 0px; padding: 10px;">

                    <div class="fusion-post-wrapper">
                   <div class="fusion-flexslider flexslider fusion-post-slideshow">
                            <ul class="slides">
                                <li class="flex-active-slide" style="width: 100%; float: left; margin-right: -100%; position: relative; opacity: 1; display: block; z-index: 2;">

                                    <div class="fusion-image-wrapper" aria-haspopup="true"> 
                                        <a href="<?php the_permalink(); ?>"> 

                                            <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID), 'thumbnail' ); ?>

                                            <img width="384" height="173" alt="" data-src="<?php echo $url ?>" class="attachment-full size-full wp-post-image lazyloaded" src="<?php echo $url ?>" draggable="false">

                                        </a>
                                    </div>
                                </li>
                            </ul>

                        </div>

                        <div class="fusion-post-content-wrapper">
                            <div class="fusion-post-content post-content">
                        <h2 class="entry-title" itemprop="headline"><a href="<?php the_permalink(); ?>" class="entry-title-link"><?php  the_title(); ?></a></h2>
                            </div>


                        <div class="fusion-meta-info">
                                <div class="fusion-alignleft"> 
                                    <a href="<?php the_permalink(); ?>" class="fusion-read-more"> Read More </a>
                                </div>
                            </div>
                        </div>
                        </div>
                   </article>


            <?php
                    endwhile;
                    endif;



            ?>



    </div>
    </div>  

    <div class="fusion-aligncenter" style="margin-top: 20px;"><a href="<?php get_site_url(); ?>/gift-vouchers/" class="fusion-button button-flat fusion-button-default-size button-default button-1 fusion-button-default-span fusion-button-default-type">Buy <?php echo $portfolio_cat_name; ?> Gift Vouchers</a></div> 






        <?php if( have_rows('feature_repeater') ): ?>
 <div class="related-posts">
        <h2>You May Also Like...</h2>
    <div>

    <?php while( have_rows('feature_repeater') ): the_row(); 

        // vars
        $image = get_sub_field('collection_image');
        $content = get_sub_field('collection_title');
        $link = get_sub_field('collection_link');

        ?>

        <div>

            <?php if( $link ): ?>
                <a href="<?php echo $link; ?>">
            <?php endif; ?>

                <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />

            <?php if( $link ): ?>
                </a>
            <?php endif; ?>

            <?php echo $content; ?>

        </div>

    <?php endwhile; ?>


        </div>
</div>
<?php else : ?>

       No Posts to Display

<?php endif; ?>



</section>          
<?php do_action( 'avada_after_content' ); ?>
<?php get_footer(); ?>
4

0 に答える 0