1175 posts
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
mabuc says

Hello wp devs,

me again, I need your help here.. I tried everything but no luck!
I have 2 loops (in my blog page template) one is in my sidebar custom widget and second is in my blog page..

here’s my custom widget code retrieved data from custom post type (portfolio)
<?php
    $args = array( 'post_type' => 'portfolio', 'posts_per_page' => 2);
    query_posts ( $args );    
    while (have_posts()) : the_post();
?>
     ...content here...
<?php
    endwhile;
    wp_reset_query();
?>
and here’s my blog post code
$args = array( 'post_type' => 'post', 'paged' => $paged );
$wp_query = new WP_Query( $args );                            
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
       ...content here...
<?php
endwhile;    
wp_reset_query(); 
            ?>
and here’s my pagination code
function pagination() {  
        global $wp_query;
        $big = 999999999;

        echo paginate_links( array(
            'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
            'format' => '?paged=%#%',
            'current' => max( 1, get_query_var('paged') ),
            'total' => $wp_query->max_num_pages,
            'type' => 'list'
        ));

    }

pagination is not working properly when this widget is activated. If I remove this widget it works perfect… I only want to display the pagination correctly..

am I missing something here.. anyone care to help me ;)

thanks
mark

439 posts
  • Bought between 50 and 99 items
  • Europe
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 5 000 and 10 000 dollars
Pixelous says

You don’t need to do second query for blog post and also you don’t need wp_reset_query(); for it. Do it only for your widget.

1175 posts
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
mabuc says

You don’t need to do second query for blog post and also you don’t need wp_reset_query(); for it. Do it only for your widget.

no no… I meant the one loop came from a sidebar widget and the other loop came from a blog page… pagination not displaying properly when I activate this widget in my blog page..

EDIT : oh seems a little problem thank you very much… you save my day ;)

by
by
by
by
by
by