WordPress.org

Ready to get started?Download WordPress

Forums

pagination not working with query_post (4 posts)

  1. anandpadia
    Member
    Posted 3 years ago #

    Hi I am trying to get this work for a long time and have gone through various help available with no avail...

    Setup - I have static page as home page and then a post page. With the post page I want to skip the first 9 blogs which I show on static page.

    Now I use CODA Slider to show the posts but every thing remains the same to my knowledge.

    When I try the Query_var Paged solution it is not working giving me the right older posts... Please find the code below... Please help...

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $wp_query = new WP_Query();
    $wp_query->query('offset=9&posts_per_page='.get_option('posts_per_page').'&paged=' . $paged);
    ?>
    
    <?php if ($wp_query->have_posts()) : ?>
    
    				<?php $c=0; ?>
    				<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    				<?php if ($c==0) : ?>
    					<div class="panel">
    				<?php endif; ?>
    
    				<div class="wrapper-archive">
    					<?php $image = get_post_meta($post->ID, 'archive_image', true); if ($image=="") { $image = get_post_meta($post->ID, 'lead_image', true); } ?>
    					<img src="<?php echo $image; ?>" alt="" width="270" height="172" />
    					<div class="post-title">
    						<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    					</div>
    					<div class="postmetadata-archive">
    					Posted on: <?php the_time('l, F jS, Y') ?><br />
    					Filed under: <?php the_category(', ') ?><br />
    					<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
    					</div>
    
    				</div>
    
    				<?php $c++; if ($c==6){ $c=0; ?>
    					</div>
    				<?php } endwhile; ?>
    				<?php if ($c==0) { ?>
    				<div class="panel" id="nav-panel">
    				<?php } ?>
    					<div class="wrapper-archive">
    						<img src="<?php bloginfo('template_directory'); ?>/images/nav-archive.png" alt="" width="270" height="172" />
    						<div class="post-title">
    							Where next?
    						</div>
    						<div class="postmetadata-archive">
    							<?php previous_posts_link('&laquo; Newer Entries  |  ') ?>
    							<?php next_posts_link('Older Entries &raquo;') ?>
    						</div>
    					</div>
    				</div>
    
    			<?php else : ?>
    
    			<?php endif; ?>
    
                            <?php wp_reset_query(); ?>
    
    			</div><!-- .panelContainer -->
    		</div><!--.stripViewer -->
    
    	</div><!-- .mid -->
  2. yagraph
    Member
    Posted 3 years ago #

    I'd advice to read this article, it worked for me :
    http://weblogtoolscollection.com/archives/2008/04/13/define-your-own-wordpress-loop-using-wp_query/

    especially, the second part : "Update: Using Pagination"

  3. anandpadia
    Member
    Posted 3 years ago #

    Thanks yagraph, Its still not working with the query.

    I think somewhere CODA Slider code is dominating the output and hence it is not working... Please suggest.

  4. chinmoy
    Member
    Posted 3 years ago #

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $wp_query = new WP_Query('offset=9&posts_per_page='.get_option('posts_per_page').'&paged=' . $paged);
    ?>
    
    <?php if (have_posts()) : ?>
    
    				<?php $c=0; ?>
    				<?php while (have_posts()) : the_post(); ?>
    				<?php if ($c==0) : ?>
    					<div class="panel">
    				<?php endif; ?>

    Use this part.

Topic Closed

This topic has been closed to new replies.

About this Topic