0
votes

Can't get the pagnation to work on the custom post types category page. It works when displaying the custom archive page. When I click on the pagnation it shows the posts from the first page but the URL says page=2.

This is the code i'm using in the archive-slug.php. How can I customize it to work with the taxonomy-slug.php?

$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
query_posts( array( 'post_type' => 'dropshippers', 'paged' => $paged ) );
$loop = new WP_Query( array( 'post_type' => 'dropshippers', 'paged' => get_query_var( 'paged' ), 'posts_per_page' => 8 ) );
if(have_posts()) : while(have_posts()) : the_post();

//Posts

endwhile; endif;

if(function_exists('wp_pagenavi')) {
wp_pagenavi( array( 'query' => $loop ) );
} else { 
echo "No posts";
}
1

1 Answers

1
votes

You need to add the name of you category in your query, i prefer to use get_posts for that:

<?php $args = array(
    'posts_per_page'   => 8,
    'offset'           => 0,
    'category'         => '',
    'category_name'    => '',
    'orderby'          => 'date',
    'order'            => 'DESC',
    'include'          => '',
    'exclude'          => '',
    'meta_key'         => '',
    'meta_value'       => '',
    'post_type'        => 'dropshippers',
    'post_mime_type'   => '',
    'post_parent'      => '',
    'author'       => '',
    'post_status'      => 'publish',
    'suppress_filters' => true 
);
$posts_array = get_posts( $args ); ?>

Fullfit this two line with your args:

'category'         => '',
'category_name'    => '',