本文整理汇总了PHP中TimberHelper::paginate_links方法的典型用法代码示例。如果您正苦于以下问题:PHP TimberHelper::paginate_links方法的具体用法?PHP TimberHelper::paginate_links怎么用?PHP TimberHelper::paginate_links使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimberHelper
的用法示例。
在下文中一共展示了TimberHelper::paginate_links方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_pagination
/**
* Get pagination.
*
* @param array $prefs
* @return array mixed
*/
public static function get_pagination($prefs = array())
{
global $wp_query;
global $paged;
global $wp_rewrite;
$args = array();
$args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']);
if ($wp_rewrite->using_permalinks()) {
$url = explode('?', get_pagenum_link(0));
if (isset($url[1])) {
parse_str($url[1], $query);
$args['add_args'] = $query;
}
$args['format'] = 'page/%#%';
$args['base'] = trailingslashit($url[0]) . '%_%';
} else {
$big = 999999999;
$args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big)));
}
$args['type'] = 'array';
$args['current'] = max(1, get_query_var('paged'));
$args['mid_size'] = max(9 - $args['current'], 3);
$args['prev_next'] = false;
if (is_int($prefs)) {
$args['mid_size'] = $prefs - 2;
} else {
$args = array_merge($args, $prefs);
}
$data = array();
$data['current'] = $args['current'];
$data['total'] = $args['total'];
$data['pages'] = TimberHelper::paginate_links($args);
$next = get_next_posts_page_link($args['total']);
if ($next) {
$data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next');
}
$prev = previous_posts(false);
if ($prev) {
$data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev');
}
if ($paged < 2) {
$data['prev'] = '';
}
return $data;
}
示例2: get_pagination
public static function get_pagination($prefs = array())
{
global $wp_query;
global $paged;
$args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']);
if (strlen(trim(get_option('permalink_structure')))) {
$args['format'] = 'page/%#%';
$args['base'] = trailingslashit(get_pagenum_link(0)) . '%_%';
} else {
$big = 999999999;
$args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big)));
}
$args['type'] = 'array';
$args['current'] = max(1, get_query_var('paged'));
$args['mid_size'] = max(9 - $args['current'], 3);
$args['prev_next'] = false;
if (is_int($prefs)) {
$args['mid_size'] = $prefs - 2;
} else {
$args = array_merge($args, $prefs);
}
$data['pages'] = TimberHelper::paginate_links($args);
$next = next_posts($args['total'], false);
if ($next) {
$data['next'] = array('link' => $next, 'class' => 'page-numbers next');
}
$prev = previous_posts(false);
if ($prev) {
$data['prev'] = array('link' => $prev, 'class' => 'page-numbers prev');
}
if ($paged < 2) {
$data['prev'] = '';
}
return $data;
}