我试图将分页添加到我的WordPress网站,它在主索引页中运行良好,我试图为类别问题创建不同的主页,当单击分页URL的任何链接时,内容仍然相同,但索引页代码
<?php
if (have_posts()) :
while (have_posts()) : the_post();
/* post code goes here */
endwhile;
the_posts_pagination( array(
\'mid_size\' => 2,
\'prev_text\' => __( \'Back\', \'textdomain\' ),
\'next_text\' => __( \'Onward\', \'textdomain\' ),
) );
else :
echo \'<p>No content found</p>\';
endif;?>
类别页面代码
<?php
query_posts(\'cat=5\');
if (have_posts()) :
while (have_posts()) : the_post();
/* post code goes here */
endwhile;
the_posts_pagination( array(
\'mid_size\' => 2,
\'prev_text\' => __( \'Back\', \'textdomain\' ),
\'next_text\' => __( \'Onward\', \'textdomain\' ),
) );
else :
echo \'<p>No content found</p>\';
endif;?>
我也试过这个
<ul>
<?php
global $post;
$myposts = get_posts( array(
\'offset\' => 1,
\'category\' => 5
) );
if ( $myposts ) {
foreach ( $myposts as $post ) :
setup_postdata( $post ); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php
endforeach;
wp_reset_postdata();
}
the_posts_pagination( array(
\'mid_size\' => 2,
\'prev_text\' => __( \'Back\', \'textdomain\' ),
\'next_text\' => __( \'Onward\', \'textdomain\' ),
) );
?>
</ul>
但只显示post,不显示分页
有人能帮忙吗提前谢谢你的帮助