• I have a home page with two initial loops showing four posts (two on each column with two different categories and then the regular loop starts again. The code has been inserted on a custom page template.

    So far everything seems to be working fine, but when I try to get the third loop (the regular one) to start on the third post (offset of two posts) my pagination gets corrupted and page 2 and further only show page one. This code seems to be working:

    $posts = query_posts(array( 'cat' => -30, 'paged' => get_query_var('page')));

    But when I change it to this:

    $posts = query_posts(array( 'cat' => -30, 'paged' => get_query_var('page'), 'offset' => 2));

    My pagination stops working.

    Anybody knows what I’m doing wrong?

    I will copy the entire code here (line 137 is not being used now, and line 138 is where the problem seems to be):

    <?php
      /*
      Template Name: Alternate Multi Column Home
      */
    ?>
    <?php get_header(); ?>
    <div class="multicolumna">
    <div class="art-content-layout">
        <div class="art-content-layout-row">
            <div class="art-layout-cell art-content">
    			<?php
    			  get_sidebar('top'); 
    
    			  global $post;
    			  if (have_posts()){
    
    				?>
    				<div class = "todo">
    				<div class = "columna1">
    				<span class="cabeceracolumna">Noticias de Las Rozas:</span>
    				<div class="cleared"></div>
    				<?php
    				$i = 0;
    				$args = 'cat=' . '3' . '&orderby=date&order=ASC'.'&offset=' . $offs;
    				$posts = query_posts( $args );
    				while (have_posts()& $i <2)
    				{
    				?>
    				<div class = "entrada">
    				<?php
    					the_post();
    					?>
    
    					<?php
    					art_post_wrapper(
    						array(
    								'id' => art_get_post_id(),
    								'class' => art_get_post_class(),
    								'thumbnail' => art_get_post_thumbnail(),
    								'title' => '<a href="'.get_permalink($post->ID).'" rel="bookmark" title="'.get_the_title().'">'.get_the_title().'</a>',
    								'content' => art_get_excerpt(), // 'content' => 'My post content',
    
    						)
    					);
    					$i++;
    				?>
    					<!--
    					<span class="post-date">
    						<span class="month">
    						<?php the_time(__('M','arclite')); ?>
    						</span>
    						<span class="day">
    						<?php the_time(__('j','arclite')); ?>
    						</span>
    					</span>
    					<div class="post-author">
    						<span class="info">
    						<?php printf(__('Autor: %s','arclite'),'<a href="'. get_author_posts_url(get_the_author_ID()) .'" title="'. sprintf(__("Mensajes por %s","arclite"), attribute_escape(get_the_author())).' ">'. get_the_author() .'</a>');
    						?>
    						</span>
    					</div>
    					-->
    				</div>
    				<?php
    				}
    				wp_reset_postdata();
    				wp_reset_query();
    				?>
    				</div>
    				<div class = "columna2">
    				<span class="cabeceracolumna">Colaboraciones y Blog:</span>
    				<div class="cleared"></div>
    				<?php
    				$i = 0;
    				$args = 'cat=' . '30' . '&orderby=date&order=ASC'.'&offset=' . $offs;
    				$posts = query_posts( $args );
    				while (have_posts()& $i <2)
    				{
    				?>
    				<div class = "entrada">
    				<?php
    					the_post();
    					?>
    
    					<?php
    					art_post_wrapper(
    						array(
    								'id' => art_get_post_id(),
    								'class' => art_get_post_class(),
    								'thumbnail' => art_get_post_thumbnail(),
    								'title' => '<a href="'.get_permalink($post->ID).'" rel="bookmark" title="'.get_the_title().'">'.get_the_title().'</a>',
    								'content' => art_get_excerpt(), // 'content' => 'My post content',
    
    						)
    					);
    					$i++;
    				?>
    					<!--
    					<span class="post-date">
    						<span class="month">
    						<?php the_time(__('M','arclite')); ?>
    						</span>
    						<span class="day">
    						<?php the_time(__('j','arclite')); ?>
    						</span>
    					</span>
    
    					<div class="post-author">
    						<span class="info">
    						<?php printf(__('Autor: %s','arclite'),'<a href="'. get_author_posts_url(get_the_author_ID()) .'" title="'. sprintf(__("Mensajes por %s","arclite"), attribute_escape(get_the_author())).' ">'. get_the_author() .'</a>');
    						?>
    						</span>
    					</div>
    					-->
    				</div>
    				<?php
    				}
    				wp_reset_postdata();
    				wp_reset_query();
    				?>
    				</div>
    				</div>
    				<div class="cleared"></div>
    				<?php
    				if (art_get_option('art_' . (art_is_home() ? 'home_' : '') . 'top_posts_navigation')) {
    					art_page_navigation();// previous_posts_link | next_posts_link
    				}
    				$args = 'cat=' . '-30' . 'orderby=date&order=ASC'.'offset=' . '2';
    				$posts = query_posts(array( 'cat' => -30, 'paged' => get_query_var('page')));
    				while (have_posts())
    				{
    					the_post();
    					art_post_wrapper(
    						array(
    								'id' => art_get_post_id(),
    								'class' => art_get_post_class(),
    								'thumbnail' => art_get_post_thumbnail(),
    								'title' => '<a href="'.get_permalink($post->ID).'" rel="bookmark" title="'.get_the_title().'">'.get_the_title().'</a>',
    								'before' => art_get_metadata_icons('date,edit', 'header'),
    								'content' => art_get_excerpt(), // 'content' => 'My post content',
    								'after' => art_get_metadata_icons('category,tag,comments', 'footer')
    						)
    					);
    				?>
    				<div class="separar" align="center"><img src="wp-content/themes/Miguel_angel_ferrero/images/post_separator.jpg"/></div>
    				<?php
    				}
    				wp_reset_postdata();
    				if (art_get_option('art_bottom_posts_navigation')) {
    					art_page_navigation();// previous_posts_link | next_posts_link
    				}
    			  } else {    
    
    				art_404_content();
    
    			  }
    				wp_reset_postdata();
    				wp_reset_query();
    			get_sidebar('bottom');
    			?>
              <div class="cleared"></div>
            </div>
            <div class="art-layout-cell art-sidebar1">
              <?php get_sidebar('default'); ?>
              <div class="cleared">
            </div>
        </div>
    </div>
    <div class="cleared">
    </div>
    <?php get_footer();
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘query_posts pagination and offset’ is closed to new replies.