0
我創建了一個只顯示特定分類類別的自定義索引頁面。然而,分頁似乎不適用於自定義索引頁面。當點擊分頁時,它不能找到第1頁以外的任何頁面。它只會重定向到我的404頁面。分頁不適用於自定義頁面索引
這裏是我的自定義索引頁
<?php
/*
Template Name: Funday
*/
get_header(); ?>
<div id="post" class="col span_8 clr">
<img src="<?php bloginfo('template_url'); ?>/images/articlebar.png" alt="article bar" id="logo" style="margin-bottom: 10px" />
<?php query_posts ($query_string . '&cat=funday'); ?>
<?php
if (have_posts()) :
while (have_posts()) : the_post();
get_template_part('content', get_post_format());
endwhile;
endif;
echo '<div class="clear"></div>';
wpex_pagination(); ?>
</div><!-- .span_8 -->
<?php
get_sidebar(article);
get_footer();
這裏的分頁功能。
<?php
/**
* Custom pagination function
*/
if(! function_exists('wpex_pagination')) {
function wpex_pagination() {
global $wp_query;
$total = $wp_query->max_num_pages;
$big = 999999999; // need an unlikely integer
if($total > 1) {
if(!$current_page = get_query_var('paged'))
$current_page = 1;
if(get_option('permalink_structure')) {
$format = 'page/%#%/';
} else {
$format = '&paged=%#%';
}
echo paginate_links(array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big) )),
'format' => $format,
'current' => max(1, get_query_var('paged')),
'total' => $total,
'mid_size' => 3,
'end_size' => 1,
'type' => 'list',
'prev_text' => '«',
'next_text' => '»',
));
}
}
}
/**
* Custom page entry pagination function
*
*/
function wpex_pagejump($pages = '', $range = 4) {
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '') {
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages) {
$pages = 1;
}
}
if(1 != $pages) {
echo '<div class="post-navigation clearfix"><div class="alignleft">';
previous_posts_link('← ' . __('Newer Posts', 'wpex'));
echo '</div><div class="alignright">';
next_posts_link(__('Older Posts', 'wpex') .' →');
echo '</div></div>';
}
}