• I’m running WordPress 3.6.1 the latest version.

    Trying to paginate through WP_Query class. This’s not working.
    I’m providing the code to have a look.

    I’m sure I did something silly that’s out of my sight.

    [ Moderator note: please wrap code in backticks or use the code button. ]

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
    
             <?php
    		 	$args = array ( 'posts_per_page' => 3, 'paged' => $paged );
    		 	$the_query = new WP_Query($args); // note that the $paged function doesn't seem to be working
    		 ?>
    
    		<?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>
    
            <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    
    			<h2><a>"><?php the_title(); ?></a></h2>
                  <p> <B>Date posted: <?php the_date(); ?></B> </p>
    			<?php include ('wp-includes/meta.php' ); ?>
    
    			<div class="entry">
    				<?php //the_content() ?>
                    <?php the_excerpt(); ?>
    
    			</div>
    
    		</div>
    
    	<?php endwhile; ?>
    	<div class="nav-previous alignleft"><?php next_posts_link(); ?></div>
    	<div class="nav-next alignright"><?php previous_posts_link(); ?></div>
        <?php wp_reset_postdata(); ?>
    
    	<?php else : ?>
    
    		<h2>Not Found</h2>
    
    	<?php endif; ?>

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Having trouble with pagination.’ is closed to new replies.