我試圖讓WordPress分頁工作。WordPress分頁不起作用Page 2
我已經使用了不同的插件,並嘗試調整pagination.php函數中的代碼無濟於事。
無論我到目前爲止使用的插件或調整,頁面2,3等始終顯示相同的帖子集。
這裏是在pagination.php
<!-- Previous/More Entries -->
<div class="mdnw_pagination">
<?php if(function_exists('wp_paginate')) :
wp_paginate();
; else : ?>
<div class="p button"><?php next_posts_link(__('« Previous Posts', 'skeleton')); ?></div>
<div class="m button"><?php previous_posts_link(__('Next Posts »', 'skeleton')); ?></div>
<?php endif; ?>
</div>
<!-- </Previous/More Entries -->
下面的代碼被用於主頁博客模板代碼:
<!-- THE POST QUERY -->
<?php
wp_reset_query();
global $paged;
global $template_file;
$cat_string = '';
$format = '';
if(get_post_custom_values('blog_post_count')) :
$post_array = get_post_custom_values('blog_post_count');
$post_count = join(',', $post_array);
else :
$post_count = -1;
endif;
/* Get Category Filter */
if(get_custom_field('blog_category_filter')) :
$cats = get_custom_field('blog_category_filter');
foreach ($cats as $cat) {
$acats[] = $cat;
}
$cat_string = join(',', $acats);
endif;
$args=array(
'cat'=>$cat_string, // Query for the cat ID's (because you can't use multiple names or slugs... crazy WP!)
'posts_per_page'=>$post_count, // Set a posts per page limit
'paged'=>$paged, // Basic pagination stuff.
);
query_posts($args); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part('includes/format', $format); ?>
<?php endwhile; else: ?>
<div class="post">
<p><?php _e('Sorry, no posts matched your criteria.', 'skeleton') ?></p>
</div><!-- /.post -->
<?php endif; ?>
<?php get_template_part('includes/element', 'pagination'); ?>
<?php wp_reset_query(); ?>
</div>
我應該在任何文件中更改得到它顯示任何其他內容,但第一頁?
我會更改閱讀窗格設置,但查詢帖子功能使用我不知道的動態值。
如何改變或改變它以使其工作?
我試圖https://wordpress.stackexchange.com/questions/105977/wordpress-pagination-not-working-always-showing-first-pages-content此頁面上的解決辦法,但無濟於事:
這是我改變了代碼:
<?php
wp_reset_query();
global $paged;
global $template_file;
$cat_string = '';
$format = '';
if(get_post_custom_values('blog_post_count')) :
$post_array = get_post_custom_values('blog_post_count');
$post_count = join(',', $post_array);
else :
$post_count = -1;
endif;
/* Get Category Filter */
if(get_custom_field('blog_category_filter')) :
$cats = get_custom_field('blog_category_filter');
foreach ($cats as $cat) {
$acats[] = $cat;
}
$cat_string = join(',', $acats);
endif;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args=array(
'cat'=>$cat_string, // Query for the cat ID's (because you can't use multiple names or slugs... crazy WP!)
'posts_per_page'=> 9, // Set a posts per page limit
'paged'=>$paged, // Basic pagination stuff.
);
$your_query = new WP_Query($args); ?>
<?php if ($your_query->have_posts()) : while ($your_query->have_posts()) : $your_query->the_post(); ?>
<?php get_template_part('includes/format', $format); ?>
<?php endwhile; else: ?>
<div class="post">
<p><?php _e('Sorry, no posts matched your criteria.', 'skeleton') ?></p>
</div><!-- /.post -->
<?php endif; ?>
<?php get_template_part('includes/element', 'pagination'); ?>
<?php wp_reset_query(); ?>