1179 posts
  • Has referred 200+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+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
  • Has been part of the Envato Community for over 2 years
  • Has sold $5,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Located in Europe
+1 more
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.

1179 posts
  • Has referred 200+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+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