1180 posts
  • Affiliate Level 5
  • Author Level 5
  • Collector Level 2
  • Exclusive Author
+2 more
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

438 posts
  • 3 Years of Membership
  • Author Level 4
  • Collector Level 3
  • Exclusive Author
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.

1180 posts
  • Affiliate Level 5
  • Author Level 5
  • Collector Level 2
  • Exclusive Author
+2 more
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