这就是我为寻呼所做的。我希望它能帮助你走上正确的道路,这可能会对你正在尝试的事情造成过度伤害。。。
首先,我设置$分页:
$paged = ( get_query_var( \'paged\' ) ) ? get_query_var( \'paged\' ) : 1;
然后构建$args数组,确保调用:
\'paged\' => $paged
运行查询,包括分页所需的函数(这是一个示例,请更改所需的内容以使其成为您的):
//the query using arguments above
$wp_query = new WP_Query( $args );
//use the query for paging
$wp_query->query_vars[ \'paged\' ] > 1 ? $current = $wp_query->query_vars[ \'paged\' ] : $current = 1;
//set the "paginate_links" array to do what we would like it it. Check the codex for examples http://codex.wordpress.org/Function_Reference/paginate_links
$pagination = array(
\'base\' => @add_query_arg( \'paged\', \'%#%\' ),
//\'format\' => \'\',
\'showall\' => false,
\'end_size\' => 4,
\'mid_size\' => 4,
\'total\' => $wp_query->max_num_pages,
\'current\' => $current,
\'type\' => \'plain\'
);
//build the paging links
if ( $wp_rewrite->using_permalinks() )
$pagination[ \'base\' ] = user_trailingslashit( trailingslashit( remove_query_arg( \'s\', get_pagenum_link( 1 ) ) ) . \'page/%#%/\', \'paged\' );
//more paging links
if ( !empty( $wp_query->query_vars[ \'s\' ] ) )
$pagination[ \'add_args\' ] = array( \'s\' => get_query_var( \'s\' ) );
//run the query
if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();
剩下的就是告诉页面您希望页面链接的位置:
//print the paging links to the page
echo \'<div class="pydPaging">\' . paginate_links($pagination) . \'</div>\';
同样,这可能有点过头了,但效果很好。