I'm trying to get WordPress Pagination Working.
I've used different plugins and tried tweaking the code in the pagination.php function to no avail.
No matter what plugin or tweak I've used so far, Pages 2, 3 etc always displays the same set of posts.
Here is the code in the 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 -->
Here is the code for the blog template for the home page:
<!-- 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>
What should I change in either file to get it to show any other content but the first page?
I would change the reading pane settings but the query posts function uses a dynamic value that I'm unaware of.
How or what can I change to get it working?
I tried the solution on this page https://wordpress.stackexchange.com/questions/105977/wordpress-pagination-not-working-always-showing-first-pages-content , but to no avail:
Here is what I changed the code to:
<?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(); ?>