我遇到了麻烦
我是一个wordpress网站,我发布了category.php模板。
在我的index.php中,如果是in_category,我会显示自定义循环:
<?php get_header(); ?>
<?php if( in_category( array('peliculas','accion','animacion','aventuras','belico','ciencia-ficcion','comedia','drama','fantastico','romance','terror','thriller') ) ){
get_template_part('loop', 'peliculas');
}?>
<?php if ( in_category(array('musica','ambiente','bachata','blues','country','cuarteto','cumbia','dance','dubstep','electronica','heavy-metal','hip-hop','house','jazz','pop','reggae','reggaeton','rock-nacional','rock-internacional','salsa','soul','tecno') ) ){
get_template_part('loop', 'musica');
}?>
<?php if ( in_category(array('software') ) ) {
get_template_part('loop', 'software');
}?>
<div class="clearfix"></div>
<?php get_footer(); ?>
所有循环都相同,按标题类别显示:
<?php $currentCategory = single_cat_title("", false);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query = array(
'category_name' => $currentCategory,
'paged'=> $paged,
'posts_per_page' => '18',
'order' => 'DESC'
);
$page = new WP_Query( $query );
?>
<?php if ( $page->have_posts() ) : while ( $page->have_posts() ) : $page->the_post(); ?>
//loop items
<?php endwhile; endif; wp_reset_query(); ?>
<div class="clear"></div>
<?php pagination_links(); ?>
问题?页面始终显示! 可以帮助我吗?
如果您能看到问题的详细信息: 类别:Peliculas。 每页发布:18 链接:http://www.megadw.com/categoria/peliculas/accion/
非常感谢您的阅读!
答案 0 :(得分:0)
您应该在pagination_links()
函数中设置适当的参数。
<?php
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
global $wp_query;
$page_args = array(
'base' => add_query_arg('paged', '%#%'),
'format' => '?page=%#%',
//'total' => $post_categories->max_num_pages,
'total' => $wp_query->max_num_pages,
'current' => $page,
'show_all' => False,
'end_size' => 1,
'mid_size' => 2,
'prev_next' => True,
'prev_text' => __('« Previous'),
'next_text' => __('Next »'),
'type' => 'plain',
'add_args' => False,
'add_fragment' => '',
'before_page_number' => '',
'after_page_number' => '');
echo paginate_links($page_args);
?>
试试这个。