Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- paginação de segunda query, dentro de qualquer template page.
- */
- if (isset($_GET['pg'])) $cur_page = absint($_GET['pg']);
- else $cur_page = 1;
- $args = array( 'post_type' => 'product', 'posts_per_page' => 5, 'paged' => $cur_page );
- $wp_query = new WP_Query($args);
- while ( $wp_query->have_posts() ) : $wp_query->the_post();
- echo '<h2>' . get_the_title() . '</h2>';
- echo get_the_content(); //ou get_the_excerpt()
- endwhile;
- $page_links_total = $wp_query->max_num_pages;
- $page_links = paginate_links( array(
- 'base' => add_query_arg( 'pg', '%#%' ), //pg é a variavel que vai aparecer na url ?pg=1 ....
- 'format' => '',
- 'prev_text' => __('«'),
- 'next_text' => __('»'),
- 'total' => $page_links_total,
- 'current' => $cur_page
- ));
- if ( $page_links ) echo '<div class="paging">'. $page_links .'</div>';
- wp_reset_query();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement