Support » Plugin: WP-PageNavi » Pagination throws 404 error for custom taxonomy

  • Resolved Ashwini Naik


    Hello All,
    I have been struggling really hard to get the pagination work for custom taxonomy. Must admit I have gone through all the articles mentioned by the people who had faced similar issues. But my bad luck none of the solutions are working 🙁 🙁

    The problem is page-1 appears properly and everything is fine. But when I click on the page navigation page 2 I’m getting Error Page not found.

    Below am posting the code that is currently in my taxonomy-postype.php file. FYI:
    <?php $paged = (get_query_var(‘page’)) ? get_query_var(‘page’) : 1;
    $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) );
    global $query_string;
    $args = wp_parse_args($query_string); // to not overwrite all the original page code (the $query_string)
    $args = array(
    ‘post_type’ => ‘compressed-t-shirts’,
    ‘posts_per_page’ => 3,
    ‘paged’ => $paged,
    ‘tax_query’ => array(
    ‘taxonomy’ => ‘shapes-portfolio’,
    ‘field’ => ‘slug’,
    ‘terms’ => $term->slug

    $my_query = new WP_Query($args);

    if( $my_query->have_posts() ) {
    $i = 1;
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <?php if(has_post_thumbnail()): ?>
    <div id=”mm2″>
    “><?php the_post_thumbnail(array(200,200)); ?>
    <?php endif;?> <span><?php the_title();?></span>
    </div><?php if($i % 3 ==0) { ?>
    <img style=”width: 100%; margin-top: 30px; margin-bottom:35px;” src=”<?php echo get_stylesheet_directory_uri(); ?>/images/dot_line_blog.png” />
    <?php } $i++; endwhile;
    wp_pagenavi(array( ‘query’ => $my_query ) );
    wp_reset_postdata(); // Restore global post data stomped by the_post().

    Am using wp-pagenavi plugin.
    I have tried adding pre_get_post function in functions.php and

    Have also tried this method : function change_posttype() {
    if( is_archive() && !is_admin() ) {
    set_query_var( ‘post_type’, array( ‘post’, ‘portfolio’ ) );
    add_action( ‘parse_query’, ‘change_posttype’ );

    Also have tried the options_per_page filter adding in the functions.php file. None of the solutions have worked for me.

    Seriously I need your help. If I resolve this I can finsih up the project. Kindly help me resolve this. Any help much appreciated

    Thanks a lot in advance

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Pagination throws 404 error for custom taxonomy’ is closed to new replies.