Wordpress ACF中继器分页

Wordpress ACF中继器分页,wordpress,pagination,advanced-custom-fields,image-gallery,Wordpress,Pagination,Advanced Custom Fields,Image Gallery,我将感谢一些关于高级自定义字段转发器的帮助。问题是,我正在用插件构建一个图库,但我需要在页面末尾分页。我正在显示分页链接,但单击时它们似乎不起作用。它是否与页面的url有关?url中没有显示页码。这是我的密码: <?php /* * Paginate Advanced Custom Field repeater */ if (get_query_var('paged')) { $page = get_query_var('paged'); } else { $pag

我将感谢一些关于高级自定义字段转发器的帮助。问题是,我正在用插件构建一个图库,但我需要在页面末尾分页。我正在显示分页链接,但单击时它们似乎不起作用。它是否与页面的url有关?url中没有显示页码。这是我的密码:

<?php


/*
 * Paginate Advanced Custom Field repeater
*/

if (get_query_var('paged')) {
    $page = get_query_var('paged');
} else {
    $page = 1;
}

// Variables
$row             = 0;
$images_per_page = 2; // How many images to display on each page
$images          = get_field('thumbnail_image_repeater');
$total           = count($images);
$pages           = ceil($total / $images_per_page);
$min             = (($page * $images_per_page) - $images_per_page) + 1;
$max             = ($min + $images_per_page) - 1;
?> 

 <?php
if (have_rows('thumbnail_image_repeater')):
?> 
   <?php
    while (have_rows('thumbnail_image_repeater')):
        the_row();
        $row++;

        // Ignore this image if $row is lower than $min
        if ($row < $min) {
        continue;
        }

        // Stop loop completely if $row is higher than $max
        if ($row > $max) {
            break;
        }
?>   

 <?php
        $image          = get_sub_field('thumbnail_image');
        $thumbnail_name = get_sub_field('thumbnail_name');
?> 



    <li class="col-xs-6 col-sm-4 col-md-3" data-responsive="<?php
        echo $image['url'];
?>" data-src="<?php
        echo $image['url'];
?>" data-sub-html="<h4><?php
        echo $thumbnail_name;
?></h4><p><?php
        echo $thumbnail_name;
?></p>" data-pinterest-text="Pin it1" data-tweet-text="share on twitter 1"> 
        <a href=""> 
            <img class="img-responsive" src="<?php
        echo $image['url'];
?>" alt="Thumb-1" /> 
        </a> 
    </li> 
        <?php
    endwhile;
    // Pagination
    echo paginate_links(array(
        'base' => get_permalink() . '%#%' . '/',
        'format' => '?page=%#%',
        'current' => $page,
        'total' => $pages,
        'prev_text' => __('<<<'),
        'next_text' => __('>>>')
    ));
?> 


  <?php
endif;
?>


看起来您正在使用旧版本的分页。您仅在常规内置页面上使用函数的版本。我打赌你在自定义帖子类型上使用了这个。几年前,他对其进行了更新,以支持CPT。以下是他不得不说的:

代码段开头引用的查询变量变为 “page”而不是“paged”:

if( get_query_var('page') ) {
   $page = get_query_var( 'page' );
} else {
   $page = 1;
}
传递给paginate_链接的基本选项和格式选项变为:

'base' => get_permalink() . '%#%' . '/',
'format' => '?page=%#%',

- 

尝试将格式更改为“paged=”而不是“page=”。尝试了此操作,但无效。还有别的问题。我想wordpress没有在第二页添加/2/或在第三页添加/3/等url。您是否尝试过添加第/2页而不是第/2页?如果这没有帮助,那么我可以提出一个解决方案来注册您自己的url重写,并将其应用于您的分页。问题是,我读到你用“paged”而不是“page”,因为第二个只与主页相关,而你对其他页面使用“paged”。然而,我在博客中看到你提到的“WordPress会自动将URL段(如/2/)转换为一个名为“page”的查询变量”。例如,当我转到第二个页面时,我的URL不会转换为URL/2/,但它会直接转到gallery滑块,并且下一个页面上的图像不可见,仅显示小的img图标。
<?php







/**



 * Template Name: Testimonial Page



*/











get_header(); ?>











<?php if(function_exists('demo_custom_innner_banner_code')) demo_custom_innner_banner_code(); ?>



 <section id="inner-page">
  <div class="inner-page testimonial_page">
      <div class="container">
          <div class="row">
                <div class="col-md-12">
                    <?php
                    if( get_query_var('page') ) {
  $page = get_query_var( 'page' );
} else {
  $page = 1;
}
                    $row= 0;
                    $testimonial_per_page  = 1;
                    $testimonials = get_field( 'testimonial_section_data' );
                    $total_testimonials = count( $testimonials );
                    $pages = ceil( $total_testimonials / $testimonial_per_page );
                    $min = ( ( $page * $testimonial_per_page ) - $testimonial_per_page ) + 1;
                    $max = ( $min + $testimonial_per_page ) - 1;
                    if( have_rows('testimonial_section_data',get_the_ID()) ):
                        while( have_rows('testimonial_section_data',get_the_ID()) ) : the_row();
                        $row++;
                        // Ignore this testimonials if $row is lower than $min
                        if($row < $min) { continue; }
                        if($row > $max) { break; } 
                        $testimonial_section_name = get_sub_field('testimonial_section_name');
                        $testimonial_section_comment = get_sub_field('testimonial_section_comment');
                        $testimonial_section_review = get_sub_field('testimonial_section_review');
                        
                    ?>    
                    <div class="testimonial-list">
                            <div class="testimonialpage_main">
                                    <div class="testimonial_quote"><i class="fas fa-quote-left"></i></div>
                                            <div class="testimonial_text">
                                                <div class="review">
                                                    <?php echo $testimonial_section_review;?>
                                                </div>
                                                <?php echo $testimonial_section_comment;?>
                                                <?php if($testimonial_section_name){?>
                                                <h3>- <?php echo $testimonial_section_name;?></h3>
                                                <?php } ?>
                                            </div>
                            </div>
                    </div>
                    <?php
                         endwhile;
                         echo paginate_links( array(
                                                    'base' => get_permalink() . '%#%' . '/',
                                                    'format' => '?page=%#%',
                                                    'current' => $page,
                                                    'total' => $pages
                            ) );
                    endif;
                    ?>
                   
                    
                    
                   
                </div>
            </div>
          </div>
        </div>
      </section>



<?php

get_footer();