当前位置: 首页>>代码示例>>PHP>>正文


PHP TimberHelper::paginate_links方法代码示例

本文整理汇总了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;
 }
开发者ID:Butterwell,项目名称:timber,代码行数:51,代码来源:timber.php

示例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;
 }
开发者ID:pedrokoblitz,项目名称:centro-dialogo-aberto,代码行数:35,代码来源:timber.php


注:本文中的TimberHelper::paginate_links方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。