Skip to content

Instantly share code, notes, and snippets.

@vasylpb
Last active January 18, 2016 10:26
Show Gist options
  • Save vasylpb/6f47f3c26d784449dd34 to your computer and use it in GitHub Desktop.
Save vasylpb/6f47f3c26d784449dd34 to your computer and use it in GitHub Desktop.
WordPress Navigation
function wp_corenavi(){
global $wp_query, $wp_rewrite;
$pages = '';
$max = $wp_query->max_num_pages;
if (!$current = get_query_var('paged')) $current = 1;
$a['base'] = str_replace(999999999, '%#%', esc_url(get_pagenum_link(999999999)));
$a['total'] = $max;
$a['current'] = $current;
$total = 0; //1 - выводить текст "Страница N из N", 0 - не выводить
$a['mid_size'] = 2; //сколько ссылок показывать слева и справа от текущей
$a['end_size'] = 1; //сколько ссылок показывать в начале и в конце
$a['prev_text'] = ''; //текст ссылки "Предыдущая страница"
$a['next_text'] = ''; //текст ссылки "Следующая страница"
if ($max > 1) echo '<div class="pager">';
if ($total == 1 && $max > 1) $pages = '<span class="pages">Страница ' . $current . ' из ' . $max . '</span>'."\r\n";
echo $pages . paginate_links($a);
if ($max > 1) echo '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment