WordPress分页系统


Wordpress pagination system

我的分页系统(wordpress)有问题。它在我的搜索页面上(显示结果),目前,搜索系统仅包含 2 种帖子类型,搜索系统工作正常,但显然无法创建分页系统。我只想使用当前页面的编号创建一个简单的上一页和下一页导航。

<div class="contenu cont-menu fixed-cont aff">
<div class="page p-spe">Résults : 
<span class="blue"><?php the_search_query(); ?></span></div>
<div class="nombre"><?php global $wp_query; echo ' ' .    
$wp_query->found_posts . ' Result(s)'; ?></div>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<article class="article-menu">
<div class="article-menu a-m-sp">
<a href="<?php the_permalink(); ?>">
<span class="rollover r2"> </span>
<?php the_post_thumbnail(array(226,150)); ?>
</a>
<div class="right p-special">
<h2 class="h2-article-menu h2-ma"><a href="<?php the_permalink(); ?>">
<?php the_title(); ?></a></h2>
<p class="date"><?php the_time('j F Y'); ?></p>
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>" class="sl8">Know more</a>
</div>
</div>
<div class="sep sp-s"> </div>
</article>
<?php endwhile; ?>
<nav class="nav-pages">
<?php previous_posts_link('&laquo; Previous') ?>
<span class="nombre-pages"><?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
echo $paged.' / '.$wp_query->max_num_pages;
?></span>
<?php next_posts_link('Next &raquo;') ?>
</nav>
<?php
$wp_query = null;
$wp_query = $temp;  // Reset
?>
<?php else : ?>
<div class="aucun-resultat">
<?php _e( 'No results' ); ?>
</div>
<?php endif; ?>
<?php
get_footer();
?>

所以我在搜索结果结束之后添加了页面导航。我不知道为什么我的系统不工作。我是WordPress初学者,感谢您的帮助。伯纳德

您不需要为此进行自定义查询。只需添加paginate_links()即可生成带有箭头和数字的分页(可以配置为根据需要显示)。

http://codex.wordpress.org/Function_Reference/paginate_links

我更新了我的帖子,因为我对 1 种帖子类型进行了分页,并且工作正常。但是现在我想对 2 种帖子类型进行分页。我如何更改此代码以使其工作?

<?php 
  $temp = $wp_query; 
  $wp_query = null; 
  $wp_query = new WP_Query(); 
  $wp_query->query('showposts=4&post_type=dossiers'.'&paged='.$paged); 
  while ($wp_query->have_posts()) : $wp_query->the_post(); 
?>