我有一个几乎完全建立在页面上的网站。php模板使用高级自定义字段灵活的内容字段来确定显示的内容。作为灵活内容的一部分,我有一个引用字段,用于获取自定义帖子类型并显示它们的列表。
此引用字段的模板如下所示,它位于主WordPress循环中。
<?php
$margin = get_sub_field(\'remove_top_and_bottom_margin\');
if ($margin) {
foreach($margin as $result) {
if ($result == \'bottom\') {
$no_bottom = \'no-bottom-margin\';
}
if ($result == \'top\') {
$no_top = \'no-top-margin\';
}
}
}
?>
<?php
// Here we choose the post type to reference. This post type
// also has a flexible layout (see the get_template_part(\'templates/content\', \'flexible\').
$reference = get_sub_field(\'reference\');
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$args = array(
"post_type" => $reference,
"posts_per_page" => 1,
"paged" => $paged
);
echo \'<pre>\';
var_dump($paged);
echo \'</pre>\';
$inner_query = new WP_Query($args);
if ( $inner_query->have_posts() ) : ?>
<div class="reference <?php echo $no_top . \' \' . $no_bottom; ?>">
<?php while ( $inner_query->have_posts() ) : $inner_query->the_post(); ?>
<div class="reference-entity">
<div class="entry-title">
<h3><?php the_title(); ?></h3>
<?php get_template_part(\'templates/entry-meta\'); ?>
</div>
<?php get_template_part(\'templates/content\', \'flexible\');
?>
</div>
<?php endwhile;
if ($inner_query->max_num_pages > 1) : // check if the max number of pages is greater than 1 ?>
<nav class="prev-next-posts">
<div class="prev-posts-link">
<?php echo get_next_posts_link( \'Older Entries\', $inner_query->max_num_pages ); // display older posts link ?>
</div>
<div class="next-posts-link">
<?php echo get_previous_posts_link( \'Newer Entries\' ); // display newer posts link ?>
</div>
</nav>
<?php endif;
wp_reset_postdata(); ?>
</div>
<?php else:
echo \'No posts found. Try adding one.\';
endif;
当我单击分页链接返回时,我得到一个404错误,URL中有一个/page/2。有什么帮助吗?