I'm really stumped with this pagination problem with my custom Wordpress theme.
I have a custom page which views a list of 'books'. Everything displays correctly even the pagination. My permalink option is set to 'post name'. So when I want to see page 2 of my book list, I click on the '2' and I'm led to www.domain.com/book-list/page/2 which gives me a 404 error. However, when I change my permalink option to 'default', pagination works with ?paged=2.
I've searched for 2 days and I tried many different things but none seem to work. Would appreciate any kind of help.
Here are my methods from function.php:
function get_book_posts($type, $num, $category = ""){
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => $type,
'posts_per_page' => $num,
'paged' => $paged,
'category_name' => $category);
$new_query = new WP_Query($args);
query_posts($args);
}
function get_book_pagination(){
$args = array(
'prev_text' => __('<'),
'next_text' => __('>'));
echo paginate_links($args);}
From booklist.php
<?php $posts = get_book_posts('book', 6); ?>
<?php if(have_posts()):?>
<?php while (have_posts()):the_post()?>
<a href="<?php the_permalink();?>"><?php the_title();?></a>
<?php endwhile; ?>
<div class="pagination">
<?php get_book_pagination(); ?>
</div>
<?php wp_reset_postdata(); ?>