I am having an issue with my Pagination.
-
I am here with a new issue i am facing. When i click on page 2, 3 it shows same page. Here are my codes. First. Pagination in functions.php
function pagination($pages = '', $range = 4) { $showitems = ($range * 2)+1; global $paged; if(empty($paged)) $paged = 1; if($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if(!$pages) { $pages = 1; } } if(1 != $pages) { echo "<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>"; if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>« First</a>"; if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹ Previous</a>"; for ($i=1; $i <= $pages; $i++) { if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) { echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>"; } } if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next ›</a>"; if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last »</a>"; echo "</div>\n"; } }
Pagination.css
.pagination { margin-left:40%; margin-top:-70px; clear:both; padding:20px 0; position:relative; font-size:14px; font-weight:bold; line-height:18px; } .pagination span, .pagination a { display:block; float:left; margin: 2px 2px 2px 0; padding:6px 9px 5px 9px; text-decoration:none; width:auto; color:black; background:white; border:2px solid #e8eaeb; } .pagination a:hover{ color:black; background: rgba(144, 150, 154, 0.075); border:2px solid #e8eaeb; } .pagination .current{ padding:6px 9px 5px 9px; background: rgba(144, 150, 154, 0.075); color:black; border:2px solid #e8eaeb; }
Pagination Loop In Page Where i want to show Pagination
<?php if (function_exists("pagination")) { pagination($additional_loop->max_num_pages); } ?>
Now, The Posts i call to show on page, codes in Functions.php.
$args = array( 'offset' => 0, 'category' => '', 'category_name' => '', 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_mime_type' => '', 'post_parent' => '', 'post_status' => 'publish', 'suppress_filters' => true ); $posts_array = get_posts( $args );
This one is the Page where i am showing posts..
<?php query_posts($args); ?> <?php while (have_posts()) : the_post(); $content = get_the_excerpt(); $content2 = substr($content, 0, 100); $short_title = the_title('','',false); $short_title = substr($short_title,0,16); $id = get_the_ID(); $image = ''; if (has_post_thumbnail( $id ) ): $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' ); endif; $img = $image[0]; ?> <div class="singlepost"> <a href="<?php the_permalink() ?>"><img src="<?php echo $img; ?>"></a> <h3 style="margin-left:3%;"><?php echo $short_title; ?></h3> <p style="margin-left:3%;"><?php echo $content2; ?>...</p> <a href="<?php the_permalink() ?>" class="button" style="margin-left:3%;margin-top:-19px;">Read More →</a> </div> <?php endwhile; ?>
Please Help me to solve this issue.
- The topic ‘I am having an issue with my Pagination.’ is closed to new replies.