can't get value of global paged or page for pagination.
-
Hi! I couldn’t get the value of global paged or page to create pagination. I’ve been searching on Internet for nearly 3 hours and couldn’t figures it out.
However if I var_dump wp_query object, it show correct information of max_page and post_count :S Please help me out. Thanks in Advanced.
If I changed to $paged manually (example: $paged = 2), It is correctly offset the first paged.
if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1 ; } $args = array( 'post_type' => array($men_wear, $ladie_wear), 'posts_per_page' => $limit, 'paged' => $paged, 'meta_key' => 'post_views_count', 'orderby' => 'meta_value' ); $count = 0; $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); ?> <div class="single-product"> <a href="<?php the_permalink(); ?> "> <h2><?php the_title() ?> </h2> <?php the_post_thumbnail(); ?> </a> <?php if(function_exists("kk_star_ratings")) : echo kk_star_ratings($pid); endif; ?> <?php echo ($count % 5 == 0 ) ? ' </div>' : '</div>'; ?> <?php $count++; ?> <?php endwhile; ?> </div> <?php if (function_exists('wp_paginate')) { wp_paginate(); } wp_reset_query(); ?>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘can't get value of global paged or page for pagination.’ is closed to new replies.