在我的博客中,较旧的帖子和较新的帖子链接无法正常工作
当用户按下链接时,它只会重新加载到同一页面 网址创建的是http://www.website.com/blog/page/2/
我认为正确的网址应为http://www.website.com/blog/2014/05/page/2/
这是我在loop.php中的代码
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link( __( ' Older posts', 'twentyten' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts', 'twentyten' ) ); ?></div>
</div><!-- #nav-below -->
<?php endif; ?>
由于
答案 0 :(得分:0)
我不知道你在开始使用loop.php
时做了什么此代码可能会有所帮助。
<?php
//The Query
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$wp_query = new WP_Query();
$wp_query->query( 'showposts=10&cat='.$category_id.'&paged='.$paged );
//The Loop
while ($wp_query->have_posts()) : $wp_query->the_post();
// display posts as you need
endwhile;
// pager Method -1
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link( __( ' Older posts', 'twentyten' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts', 'twentyten' ) ); ?></div>
</div><!-- #nav-below -->
//或者您可以使用Paged Method -2
// pager
if($wp_query->max_num_pages>1){?>
<p class="pager">
<?php
for($i=1;$i<=$wp_query->max_num_pages;$i++){?>
<a href="<?php echo get_category_link($category_id).'page/'.$i;?>" <?php echo ($paged==$i)? 'class="active"':'';?>><?php echo $i;?></a>
<?php
}
if($paged!=$wp_query->max_num_pages){?>
<a href="<?php echo get_category_link($category_id).'page/'.$i;?>">Category</a>
<?php } ?>
</p>
<?php } ?>