WordPress Pagination Shows Same Page at all page numbers
-
I have just Created a New WordPress Theme. But i am failed in Pagination Step. I have created it but it is Showing Same Posts on All Paged Numbers.. Here are My Codes…
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"; } }
Style.css
` .pagination {
margin-left:25%;
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:#fff;
background:grey;
}.pagination a:hover{
color:#fff;
background: #F9611E;
}.pagination .current{
padding:6px 9px 5px 9px;
background: #F9611E;
color:#fff;
}`
And in Index.php Page Under the Posts Codes.<?php query_posts('posts_per_page=7'); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <br><br> <?php $content = get_the_content(); $trimmed_content = wp_trim_words( $content, 50, '<a href="'. get_permalink() .'">... Read More</a>' ); ?> <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <div class="title"><?php the_title(); ?></div></a> <div class="date">Posted on <?php the_time('l, F j, Y'); ?> at <?php the_time('g:i a'); ?></div> <?php the_post_thumbnail(); ?> <div class="content"><?php echo $trimmed_content; ?></div> <br><br> <hr class="phr"/><!-- //Single Post --> <?php endwhile; ?> <?php endif; ?> <hr class="phr"> </div> <div align="center"><!--//Pagination--> <?php if (function_exists("pagination")) { pagination($additional_loop->max_num_pages); } ?></div>
I have tried So much But i am watching same posts on Each Paged Posts.. To see my Page please visit this link.. https://jaylou.co/testwp/
Thanks
- The topic ‘WordPress Pagination Shows Same Page at all page numbers’ is closed to new replies.