Ich habe diese benutzerdefinierte Vorlage in Wordpress, die ein Skript enthält, das ACF-Felder paginiert. Hier ist der Quellcode:ACF Paginierung funktioniert nicht, wenn der_content vorhanden ist
<?php get_header(); ?>
<div class="container">
<div class="row">
<div class="col-xs-12">
<h1 class="pagetitle"><?php the_title(); ?></h1>
</div> <!-- col -->
</div> <!-- row -->
</div> <!-- container -->
<?php
if(get_query_var('page')) {
$page = get_query_var('page');
} else {
$page = 1;
}
$row = 0;
$files_per_page = 30; // How many images to display on each page
$files = get_field('fisier');
$total = count($files);
$pages = ceil($total/$files_per_page);
$min = (($page * $files_per_page) - $files_per_page) + 1;
$max = ($min + $files_per_page) - 1;
?>
<div class="container">
<div class="row">
<div class="col-md-8">
<section id="content">
<div class="wrapper">
<?php while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php if(have_rows('fisier')): ?>
<div class="article-files">
<h4>Files</h4>
<div class="row">
<?php while (have_rows('fisier')) : the_row();
$row++;
if($row < $min) { continue; }
if($row > $max) { break; }
?>
<div class="col-xs-12 file">
<?php $x = 0; ?>
<?php $file = get_sub_field('link'); if($file): ?>
<a href="<?php echo $file; ?>" class="file-title" target="_blank"><i class="fa fa-angle-right" aria-hidden="true"></i> <?php the_sub_field('nume_fisier'); ?></a>
<div class="file-description"><?php the_sub_field('descriere'); ?></div>
<?php $x = 1; ?>
<?php endif; ?>
<?php $file = get_sub_field('fisier_intern'); if($file): ?>
<a href="<?php echo $file; ?>" class="file-title" target="_blank"><i class="fa fa-angle-right" aria-hidden="true"></i> <?php the_sub_field('nume_fisier'); ?></a>
<div class="file-description"><?php the_sub_field('descriere'); ?></div>
<?php $x = 1; ?>
<?php endif; ?>
<?php if($x == 0): ?>
<a href="#" class="file-title"><i class="fa fa-angle-right" aria-hidden="true"></i> <?php the_sub_field('nume_fisier'); ?></a>
<div class="file-description"><?php the_sub_field('descriere'); ?></div>
<?php $x = 1; ?>
<?php endif; ?>
</div>
<?php endwhile; ?>
</div>
<div class="file-pagination">
<?php
echo paginate_links(array(
'base' => get_permalink() . '%#%' . '/',
'format' => '?page=%#%',
'current' => $page,
'show_all' => false,
'prev_text' => __('«'),
'next_text' => __('»'),
'total' => $pages
));
?>
</div> <!-- file-pagination -->
</div>
<?php endif; ?>
</div> <!-- wrapper -->
</section> <!-- content -->
</div> <!-- col -->
<div class="col-md-4">
<aside id="sidebar">
<?php get_sidebar(); ?>
</aside> <!-- aside -->
</div> <!-- col -->
</div> <!-- row -->
</div> <!-- container -->
<?php get_footer(); ?>
Der obige Code nicht die Paginierung Links nicht angezeigt, aber wenn ich diesen Teil entfernen:
<?php while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
Alles perfekt funktioniert. Irgendeine Idee darüber, wie ich das beheben kann?
Danke
Entschuldigt, wenn dies keine Hilfe ist (ich bin auf Handy, schwer zu richtig, den Code zu lesen), aber ich sehe nicht, eine Reset-Funktion nach dem Schleifenausgang. Wenn Sie möglicherweise Folgendes einfügen: 'wp_reset_postdata();' zwischen der Schleife und der Seitennummerierung kann die ursprüngliche Abfrage für die Funktion wiederhergestellt werden –