0

I have a widget which creates a grid with pagination. If I am using the pagination then it works fine when used on the page to display grid.

But when I am using that in inside a blog post. The pagination is stuck at page 1 .

This is my arg used and I have used it inside the custom query loop.

$paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
            $paged = apply_filters('pgggo_paginate_args_paged_hook', $paged);
            $args  = array(
                'format'    => 'page/%#%',
                'current'   => intval($paged),
                'total'     => intval($pgggo_query->max_num_pages),
                'mid_size'  => 2,
                'prev_text' => '<i class="fa fa-arrow-left"></i>',
                'next_text' => '<i class="fa fa-arrow-right"></i>',
            ); 

I have a few references but I am not how to use them to solve this issue.
Pagination not working with custom loop

Please help

  • Try $paged = is_singular() ? get_query_var( 'page' ) : get_query_var( 'paged' ); – Sally CJ Jul 27 at 16:13
  • @sally i was able to solve the problem by adding add_action on + $post_types = get_post_types($args, $output, $operator); + if ( is_singular( $post_types ) ) { + global $wp_query; + $page = ( int ) $wp_query->get( 'page' ); + if ( $page > 1 ) { + // convert 'page' to 'paged' + $query->set( 'page', 1 ); + $query->set( 'paged', $page ); + } + // prevent redirect + remove_action( 'template_redirect', 'redirect_canonical' ); + } +} +add_action( 'template_redirect', 'pgggo_fix_usage_single_posts',0 ); – Latheesh V M Villa Jul 28 at 18:27
  • 1
    Ok then. But perhaps you should post that code as an answer. – Sally CJ Jul 28 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.