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
  • Sells items exclusively on Envato Market
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 ;)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by