function.php
function mysite_pagenav($pages = '', $range = 2){
$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="page_nav">';
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo '<a class="first_nav" href="'.get_pagenum_link(1).'">«</a>';
if($paged > 1 && $showitems < $pages) echo '<a class="prev_nav" href="'.get_pagenum_link($paged - 1).'">‹</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 class="next_nav" href="'.get_pagenum_link($paged + 1).'">›</a>';
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo '<a class="last_nav" href="'.get_pagenum_link($pages).'">»</a>';
echo "</div>\n";
}
}
index.php
<?php global $paged;
query_posts('&paged='.$paged);
if(have_posts()) :
while(have_posts()) : // стандартный цикл вывода новостей
the_post(); ?>
<div class="news--inner">
<div class="news--inner_cont">
<a class="title" href="<?php the_permalink(); ?>">
<h2><?php the_title(); ?></h2>
</a>
<div class="date"><?php echo get_the_date(); ?></div>
<a class="miniature" href="<?php the_permalink(); ?>">
<?php
$autoimage = wpschool_first_post_img();
if( has_post_thumbnail() ) {
the_post_thumbnail('medium');
}
else {
echo '<img src="' . $autoimage . '" alt="" />';
}?>
</a>
<div class="text">
<div class="descr">
<p><?php echo trim_characters(200, '...'); ?></p>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query();?>
<div class="pagination-custom">
<?php the_posts_pagination(); ?>
</div>