• zara

    (@zarafourcommunications)


    I have a loop i need a little help with adding pagination to it so it display 6 posts per page.

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<div  <?php post_class(); ?> id="post-<?php the_ID(); ?>">
    		<h1><?php the_title(); ?></h1>
    		<?php
    $attachments = get_children(array('post_parent' => $post->ID,
    						'post_status' => 'inherit',
    						'post_type' => 'attachment',
    						'post_mime_type' => 'image',
    						'order' => 'ASC',
    						'orderby' => 'menu_order ID'));
    
    foreach($attachments as $att_id => $attachment) {
    	$full_img_url = wp_get_attachment_url($attachment->ID);
            $split_pos = strpos($full_img_url, 'wp-content');
            $split_len = (strlen($full_img_url) - $split_pos);
            $abs_img_url = substr($full_img_url, $split_pos, $split_len);
            $full_info = @getimagesize(ABSPATH.$abs_img_url);
    		$img_desc = $attachments->post_excerpt;
            ?>
    
    			<a class="popupimage" href="<?php echo $full_img_url; ?>" title="<?php echo $attachment->desc ; echo $attachment->post_content; ?>" target="_blank"><img  src="<?php echo $full_img_url; ?>" /></a>
    
    <?php
    }
    ?>
    
    		<?php the_content(); ?>
    	</div>
    
    <?php endwhile; ?>
    
    	<div class="navigation">
    		<div class="next-posts"><?php next_posts_link(); ?></div>
    		<div class="prev-posts"><?php previous_posts_link(); ?></div>
    	</div>
    
    <?php else : ?>
    
    	<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
    		<h1>Not Found</h1>
    	</div>
    
    <?php endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • set the number 6 under
    dashboard – settings – readingBlog pages show at most [ 6 ] posts

    the code for the ‘nextposts/previous posts’ is already in the posted section.

    what template file is that, and what does it show now?

    Thread Starter zara

    (@zarafourcommunications)

    Thanks That worked I am new to WordPress just started new job and and first task build site in WordPress just having a few little glitches to fix.

    Thanks

    Again

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Loop with pagination’ is closed to new replies.