Last active
August 29, 2015 14:16
-
-
Save AlexMcowkin/792848687a97cff44a79 to your computer and use it in GitHub Desktop.
wp pagination
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*in themefile*/ | |
<?php if (function_exists('wp_corenavi')) wp_corenavi(); ?> | |
?> | |
<?php | |
/*in funtion.php*/ | |
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="tf_pagination"><div class="inner">'; | |
//if ($total == 1 && $max > 1) $pages = '<span class="pages">Страница ' . $current . ' из ' . $max . '</span>'."\r\n"; | |
echo $pages . paginate_links($a); | |
if ($max > 1) echo '</div></div>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment