[英]changing permalink gives 404 eror in navigation [wordpress]
i made a page template gallery which shows custom post type named gallery which consists of a custom fields image and title Now when i run the below code and click the paginate button it directs me to http://localhost/KURDC/gallery/page/2/ and it redirects me to 404 page . 我制作了一个页面模板库 ,该库显示了一个名为gallery的自定义帖子类型,其中包含一个自定义字段图像和标题,现在当我运行以下代码并单击分页按钮时,它会将我定向到http:// localhost / KURDC / gallery / page / 2 /并且将我重定向到404 page。 why is the pagination not working ?
为什么分页不起作用?
But when i change the permalink to default it works ! 但是,当我将永久链接更改为默认设置时,它将起作用! what is the problem with change in 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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.