Leave a Reply

132 Comments on "WordPress Pagination Tutorial (Custom Query & Template Integration)"

Notify of
avatar

Japi Sandhu
Guest
Japi Sandhu
7 months 8 days ago
It still wont work for me, very frustrated have been attempting to fix this issue for 2 weeks. Please help What am I doing wrong?? <?php $ourCurrentPage = get_query_var('page'); $args = array( 'posts_per_page' => 3, 'page' => $ourCurrentPage ); // Instantiate custom query $custom_query = new WP_Query( $args ); // Output custom query loop if ( $custom_query->have_posts() ) : while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?> <h3 class="entry-title"><?php the_title(); ?></h3> <p><?php the_content(); ?></p> <?php endwhile; echo paginate_links(array( 'total' => $custom_query->max_num_pages)); endif; ?>
Sylvain Schellenberger
Guest
Sylvain Schellenberger
6 months 26 days ago

I see you use 'page' both in get_query_var() and your WP_Query, which is the syntax for querying other pages inside a page.If you want to query posts inside a page, use get_query_var('page') and WP_Query( array( 'paged' => $yourNumber ) );At least that's what bothered me today.

Japi Sandhu
Guest
Japi Sandhu
7 months 8 days ago
It still wont work for me, very frustrated have been attempting to fix this issue for 2 weeks. Please help What am I doing wrong?? <?php $ourCurrentPage = get_query_var('page'); $args = array( 'posts_per_page' => 3, 'page' => $ourCurrentPage ); // Instantiate custom query $custom_query = new WP_Query( $args ); // Output custom query loop if ( $custom_query->have_posts() ) : while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?> <h3 class="entry-title"><?php the_title(); ?></h3> <p><?php the_content(); ?></p> <?php endwhile; echo paginate_links(array( 'total' => $custom_query->max_num_pages)); endif; ?>
Sylvain Schellenberger
Guest
Sylvain Schellenberger
6 months 26 days ago

I see you use 'page' both in get_query_var() and your WP_Query, which is the syntax for querying other pages inside a page.If you want to query posts inside a page, use get_query_var('page') and WP_Query( array( 'paged' => $yourNumber ) );At least that's what bothered me today.

Manoel Vasconcelos
Guest
Manoel Vasconcelos
8 months 11 days ago

Hi, I've been looking for this information for weeks and now you've helped me.I'm with the happy with project completed.Thank you very much!

Manoel Vasconcelos
Guest
Manoel Vasconcelos
8 months 11 days ago

Hi, I've been looking for this information for weeks and now you've helped me.I'm with the happy with project completed.Thank you very much!

Umer Hassan
Guest
Umer Hassan
8 months 16 days ago

Perfect..!!! thank you…

Umer Hassan
Guest
Umer Hassan
8 months 16 days ago

Perfect..!!! thank you…

martinpepa
Guest
martinpepa
8 months 21 days ago

te pasaste nero, bien ahí diria jimenez

martinpepa
Guest
martinpepa
8 months 21 days ago

te pasaste nero, bien ahí diria jimenez

Richard Norby
Guest
Richard Norby
8 months 29 days ago

Excellent!

Richard Norby
Guest
Richard Norby
8 months 29 days ago

Excellent!

1 5 6 7 8 9 12
wpDiscuz