Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've stumble across an issue on a site Im building. I have tabbed content each holding a category for price ranges in seprate loops. The tabs work great filtering the categories, however some of the posts now have WP page-navi running the pagination, again works fine.

However if I paginate to /page/2 on the first tab the other tabs are then blank/contentless. I can only assume this is a url problem in the pagination so loops are not grabbing the content or I'm not running the loops correctly.

<div id="tabs-1">
     <?php
     $cat_id = get_query_var('cat');
     $limit = get_option('posts_per_page');
     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
     query_posts('showposts=' . $limit = 12 . '&paged=' . $paged .'&cat=' . $cat_id . '');
     $wp_query->is_archive = true; $wp_query->is_home = false;
     ?>
        <?php if (have_posts()) : ?>        
            <?php while (have_posts()) : the_post(); ?> 
                <div class="child-cat-wrap">    
                <div class="child-cat-cont title-slide">      
                 <a href="<?php the_permalink() ?>">

                <div class="title"><span><?php the_title(); ?></span>Read More</div>

                <?php the_post_thumbnail( 'Full Size' ); ?>     
                </a>
                </div>

                <?php echo get_new_excerpt() . '...'; ?>
                <a href="<?php the_permalink(); ?>">more info <span class="meta-nav">&rarr;</span></a>   


                </div>
            <?php endwhile; ?>
            <?php wp_pagenavi(); ?>
        <?php endif ?>
    </div>
    <div id="tabs-2">
     <?php
     $cat_id = get_query_var('cat');
     $limit = get_option('posts_per_page');
     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
     query_posts('showposts=' . $limit = 12 . '&paged=' . $paged .'&cat=-16,-17,' . $cat_id . '');
     $wp_query->is_archive = true; $wp_query->is_home = false;
     ?>
        <?php if (have_posts()) : ?>        
            <?php while (have_posts()) : the_post(); ?> 
                <div class="child-cat-wrap">    
                <div class="child-cat-cont title-slide">      
                 <a href="<?php the_permalink() ?>">

                <div class="title"><span><?php the_title(); ?></span>Read More</div>

                <?php the_post_thumbnail( 'Full Size' ); ?>     
                </a>
                </div>

                <?php echo get_new_excerpt() . '...'; ?>
                <a href="<?php the_permalink(); ?>">more info <span class="meta-nav">&rarr;</span></a> 


                </div>
            <?php endwhile; ?> 
            <?php wp_pagenavi(); ?>  
        <?php endif ?>
    </div>

Any information on this is even possible or a kick in the right direction would be greatly appreciated.

To see the example of the of page I'm testing

share|improve this question
1  
As starting point, you have to read this: wordpress.stackexchange.com/questions/1753/… –  brasofilo Oct 24 '13 at 20:56
1  
Thanks brasofilo thats opened my eyes with the loop. Seems i need to be running a wp Query instead of query_posts. Thats will give me a start with new ideas thanks man much appreciated –  Jamie Gill Oct 24 '13 at 21:16
    
Great stuff, managed to split the loops and run them in different variables. Then split the pagination to run in a different format so each tab has a completely seperat pagination in each loop. Thanks again for a kick in the right direction Brasofilo really appreciated its been bending my head for days! –  Jamie Gill Oct 25 '13 at 10:33
    
Bravo! :) Would be nice if you added a brief answer down here, so future readers can know the exact solution. –  brasofilo Oct 25 '13 at 10:35
    
No problem, sorry for the delay I am currently tackling another problem on the site pulls hair out. Thanks again. –  Jamie Gill Oct 31 '13 at 7:43

1 Answer 1

Ok solved,

I managed to run a query for each post as a WP_Query instead as Brasofilo pointed out. Then built in the custom pagination via wordpresses help rather than WP_navi as this would not split into sections on one page. As Follows is my new query :-

<?php
$cat_id = get_query_var('cat');
         $limit = get_option('posts_per_page');
         $paged1 = isset( $_GET['paged1'] ) ? (int) $_GET['paged1'] : 1;
         $the_querynew = new WP_Query('showposts=' . $limit = 45 . '&paged=' . $paged1 .'&cat=' . $cat_id . '');?> 

$paged1 picking up the single pagination and then running the pagination at the bottom of the page as follows :-

<?php  $catstring = get_query_var('cat');
$url = get_category_link( $catstring );
$pag_args1 = array(
'prev_text'    => __('<'),
'next_text'    => __('>'),
'show_all' => true,
'base'         => '' . $url . '?paged1=%#%',                
    'format'  => '?paged1=%#%',
    'current' => $paged1,
    'total'   => $the_querynew->max_num_pages); 
    echo paginate_links( $pag_args1 ); ?>

So simply re running the same query for different posts but running a different variable for the WP_query and $paged1 will give you the correct result.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.