我制作了一个页面模板gallery,它显示了名为gallery的自定义帖子类型,该类型由自定义字段图像和标题组成现在,当我运行下面的代码并单击分页按钮时,它会引导我http://localhost/KURDC/gallery/page/2/它将我重定向到404页面。为什么分页不起作用?
但是当我将永久链接更改为默认值时,它就起作用了!permalink的变化有什么问题?
<?php /*template name:gallery*/ ?>
<?php
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('showposts=2&post_type=gallery'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('showposts=2&post_type=gallery'.'&paged='.$paged);
$image = get_field( 'photo' );
$url = $image['url'];
?>
<div class="galleryContainer">
<img src="<?php echo $url; ?>">
<div class="caption"><?php the_field('title'); ?></div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
<nav>
<div class="right">
<?php previous_posts_link('« Newer') ?>
<div class="left">
<?php next_posts_link('« Older ') ?>
</div>
找到了我自己问题的答案:D将代码添加到自定义帖子类型保存了我:)
'rewrite' => array('slug' => 'slug-name','with_front' => FALSE)