【发布时间】:2015-07-24 18:34:55
【问题描述】:
在我的 wordpress 中,我有很多帖子,每页显示 5 个帖子。
我的页面底部有下一个和上一个按钮。当我单击一个下一个按钮时,它将转到/page/2/ 链接,但此页面标题显示Page not found。而且它没有在第 2 页显示其他帖子。
我的下一个和上一个代码:
<div class="prev-next-btn">
<?php next_posts_link( __( 'next', 'themename' ) ); ?>
</div>
<div class="prev-next-btn">
<?php previous_posts_link( __( 'prev', 'themename' ) ); ?>
</div>
我的 index.php 代码:
<div class="center-content">
<ul>
<?php query_posts('posts_per_page=5'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li>
<div class="date">In
<?php
$category = get_the_category();
if(!empty($category))
echo '<a href="'.get_category_link($category[0]->term_id ).'">'.$category[0]->cat_name.'</a>';
?>
- <?php the_time('d M, Y') ?>
</div>
<!--<div class="auther">by <?php the_author(); ?> <span> - <?php comments_number( 'no comments', 'one comment', '% comments' ); ?> Reply</span></div>-->
<div class="title clear-both"><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2></div>
<div class="details"><p><?php the_excerpt(); ?></p></div>
<div class="readmore"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">Read more</a></div>
<br>
</li>
<?php endwhile; ?>
</ul>
</div>
<div class="pagination">
<?php
if(function_exists('wp_pagenavi')) {
wp_pagenavi();
}
else {
?>
<div class="prev-next-btn">
<?php next_posts_link( __( 'next', 'themename' ) ); ?>
</div>
<div class="prev-next-btn">
<?php previous_posts_link( __( 'prev', 'themename' ) ); ?>
</div>
<?php } ?>
</div>
<?php else : ?>
404 Nothing here. Sorry.
<?php endif; ?>
</div>
【问题讨论】:
-
发布按钮的代码没用,按钮有效。问题可能是您的查询、永久链接结构、SEO 插件冲突...
-
如果您只向我们提供此信息,则无法回答此问题。我们需要完成上下文,而不仅仅是一小部分
-
我刚刚添加了我的完整上下文。你能看看
-
也可能是 .htaccess 问题。
-
.htaccess 中的确切问题是什么。你能告诉我