當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。