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


PHP paginate_links函数代码示例

本文整理汇总了PHP中paginate_links函数的典型用法代码示例。如果您正苦于以下问题:PHP paginate_links函数的具体用法?PHP paginate_links怎么用?PHP paginate_links使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了paginate_links函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: farmtoyou_paging_nav

    /**
     * Display navigation to next/previous set of posts when applicable.
     *
     * @since Farmtoyou 1.0
     *
     * @global WP_Query   $wp_query   WordPress Query object.
     * @global WP_Rewrite $wp_rewrite WordPress Rewrite object.
     */
    function farmtoyou_paging_nav()
    {
        global $wp_query, $wp_rewrite;
        // Don't print empty markup if there's only one page.
        if ($wp_query->max_num_pages < 2) {
            return;
        }
        $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
        $pagenum_link = html_entity_decode(get_pagenum_link());
        $query_args = array();
        $url_parts = explode('?', $pagenum_link);
        if (isset($url_parts[1])) {
            wp_parse_str($url_parts[1], $query_args);
        }
        $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
        $pagenum_link = trailingslashit($pagenum_link) . '%_%';
        $format = $wp_rewrite->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
        $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit($wp_rewrite->pagination_base . '/%#%', 'paged') : '?paged=%#%';
        // Set up paginated links.
        $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $wp_query->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('&larr; Previous', 'farmtoyou'), 'next_text' => __('Next &rarr;', 'farmtoyou')));
        if ($links) {
            ?>
	<nav class="navigation paging-navigation" role="navigation">
		<div class="pagination loop-pagination">
			<?php 
            echo $links;
            ?>
		</div><!-- .pagination -->
	</nav><!-- .navigation -->
	<?php 
        }
    }
开发者ID:abcode619,项目名称:wpstuff,代码行数:40,代码来源:template-tags.php

示例2: my_pagenavi

function my_pagenavi($recent)
{
    global $wp_query;
    /* $i = 0;
       foreach($wp_query->posts as $post){
           $cat = get_the_category( $post->ID );
           if($cat[0]->name == 'Блог'){
               $i++;
           }
       }*/
    $big = 999999999;
    // уникальное число для замены
    $args = array('base' => '?page=%_%', 'format' => '%#%', 'total' => $recent->max_num_pages, 'show_all' => TRUE, 'current' => isset($_GET['page']) ? $_GET['page'] : 1, 'end_size' => 1, 'mid_size' => 2, 'prev_next' => true, 'prev_text' => '<img src="' . TM_URL . '/img/LEFT-ARROW.png" alt="">', 'next_text' => '<img src="' . TM_URL . '/img/RIGHT-ARROW.png" alt="">', 'type' => 'array', 'add_fragment' => '', 'add_args' => False, 'before_page_number' => '', 'after_page_number' => '');
    $result = paginate_links($args);
    if (is_array($result)) {
        // $paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
        echo '<ul class="pagination">';
        foreach ($result as $page) {
            echo '<li>' . $page . '</li>';
        }
        echo '</ul>';
    }
    // удаляем добавку к пагинации для первой страницы
    //$result = str_replace( '/page/1/', '', $result );
}
开发者ID:Kirbaba,项目名称:RusMusic,代码行数:25,代码来源:functions.php

示例3: do_paging

 function do_paging()
 {
     if ($this->total_users_for_query > $this->users_per_page) {
         // have to page the results
         $this->paging_text = paginate_links(array('total' => ceil($this->total_users_for_query / $this->users_per_page), 'current' => $this->page, 'prev_text' => '&laquo; Previous Page', 'next_text' => 'Next Page &raquo;', 'base' => 'users.php?%_%', 'format' => 'userspage=%#%', 'add_args' => array('usersearch' => urlencode($this->search_term))));
     }
 }
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:7,代码来源:users.php

示例4: my_simone_paging_nav

    /**
     * Display navigation to next/previous set of posts when applicable.
     *
     * @return void
     */
    function my_simone_paging_nav()
    {
        // Don't print empty markup if there's only one page.
        if ($GLOBALS['wp_query']->max_num_pages < 2) {
            return;
        }
        $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
        $pagenum_link = html_entity_decode(get_pagenum_link());
        $query_args = array();
        $url_parts = explode('?', $pagenum_link);
        if (isset($url_parts[1])) {
            wp_parse_str($url_parts[1], $query_args);
        }
        $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
        $pagenum_link = trailingslashit($pagenum_link) . '%_%';
        $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
        $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
        // Set up paginated links.
        $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 2, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'my-simone'), 'next_text' => __('Next →', 'my-simone'), 'type' => 'list'));
        if ($links) {
            ?>
	<nav class="navigation paging-navigation" role="navigation">
		<h1 class="screen-reader-text"><?php 
            _e('Posts navigation', 'my-simone');
            ?>
</h1>
			<?php 
            echo $links;
            ?>
	</nav><!-- .navigation -->
	<?php 
        }
    }
开发者ID:sintija,项目名称:wordpress_backup,代码行数:38,代码来源:template-tags.php

示例5: get_pager_links

 function get_pager_links($page_url = '', $args = array())
 {
     global $wpdb;
     // page url
     if ($page_url) {
         $this->page_url = $page_url;
     }
     // total
     $this->row_count = $wpdb->get_var("SELECT FOUND_ROWS() AS row_count");
     // page count
     $this->page_count = ceil($this->row_count / $this->page_limit);
     // text
     $paging_text = '';
     // when greater
     if ($this->row_count > $this->page_limit) {
         // have to page the results
         // text
         $paging_text = paginate_links(array('total' => $this->page_count, 'current' => $this->page_current, 'base' => $this->page_url . (!preg_match('/\\?/', $this->page_url) ? '?' : '&') . '%_%', 'format' => $this->page_no . '=%#%', 'add_args' => $args));
         // format
         if ($paging_text) {
             $paging_text = sprintf('<span class="displaying-num">' . __('Displaying %d-%d of %d records ', 'mgm') . '</span> %s', number_format_i18n(($this->page_current - 1) * $this->page_limit + 1), number_format_i18n(min($this->page_current * $this->page_limit, $this->row_count)), number_format_i18n($this->row_count), $paging_text);
         }
     }
     // return
     return str_replace('page-numbers', '', $paging_text);
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:26,代码来源:mgm_pager.php

示例6: falcon_pagination

function falcon_pagination()
{
    global $wp_query;
    $big = 999999999;
    // need an unlikely integer
    return '<div class="falcon-pagination-wrapper">' . paginate_links(array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages)) . '</div>';
}
开发者ID:mfalkus,项目名称:falcon,代码行数:7,代码来源:functions.php

示例7: do_paging

 function do_paging()
 {
     if ($this->total_users_for_query > $this->users_per_page) {
         // have to page the results
         $args = array();
         if (!empty($this->search_term)) {
             $args['s'] = urlencode($this->search_term);
         }
         if (!empty($this->role)) {
             $args['role'] = urlencode($this->role);
         }
         if (!empty($this->sub_id)) {
             $args['sub_op'] = urlencode($this->sub_id);
             $args['doactionsub'] = 'Filter';
         }
         if (!empty($this->level_id)) {
             $args['level_op'] = urlencode($this->level_id);
             $args['doactionlevel'] = 'Filter';
         }
         $this->paging_text = paginate_links(array('total' => ceil($this->total_users_for_query / $this->users_per_page), 'current' => $this->page, 'base' => 'admin.php?page=membershipmembers&%_%', 'format' => 'userspage=%#%', 'add_args' => $args));
         if ($this->paging_text) {
             $this->paging_text = sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s', 'membership') . '</span>%s', number_format_i18n(($this->page - 1) * $this->users_per_page + 1), number_format_i18n(min($this->page * $this->users_per_page, $this->total_users_for_query)), number_format_i18n($this->total_users_for_query), $this->paging_text);
         }
     }
 }
开发者ID:hscale,项目名称:webento,代码行数:25,代码来源:class.membersearch.php

示例8: flat_paging_nav

function flat_paging_nav()
{
    // Don't print empty markup if there's only one page.
    if ($GLOBALS['wp_query']->max_num_pages < 2) {
        return;
    }
    $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
    $pagenum_link = html_entity_decode(get_pagenum_link());
    $query_args = array();
    $url_parts = explode('?', $pagenum_link);
    if (isset($url_parts[1])) {
        wp_parse_str($url_parts[1], $query_args);
    }
    $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
    $pagenum_link = trailingslashit($pagenum_link) . '%_%';
    $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
    $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
    // Set up paginated links.
    $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 4, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('<i class="fa fa-chevron-left"></i>', 'flat'), 'next_text' => __('<i class="fa fa-chevron-right"></i>', 'flat')));
    $allowed_html = array('a' => array('href' => array(), 'class' => array()), 'span' => array('class' => array()), 'i' => array('class' => array()));
    if ($links) {
        ?>
		<nav class="navigation paging-navigation" role="navigation">
			<div class="nav-links">
				<?php 
        echo wp_kses($links, $allowed_html);
        ?>
			</div>
		</nav>
	<?php 
    }
}
开发者ID:pivaker,项目名称:driverschool,代码行数:32,代码来源:template-tags.php

示例9: nexus_pagination

function nexus_pagination()
{
    $prev_arrow = is_rtl() ? '&laquo;' : '&laquo;';
    $next_arrow = is_rtl() ? '&raquo;' : '&raquo;';
    global $wp_query;
    $total = $wp_query->max_num_pages;
    $big = 999999999;
    // need an unlikely integer
    if ($total > 1) {
        if (!($current_page = get_query_var('paged'))) {
            $current_page = 1;
        }
        if (get_option('permalink_structure')) {
            $format = 'page/%#%/';
        } else {
            $format = '&paged=%#%';
        }
        $pages = paginate_links(array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => $format, 'current' => max(1, get_query_var('paged')), 'total' => $total, 'mid_size' => 4, 'end_size' => 4, 'type' => 'array', 'prev_text' => $prev_arrow, 'next_text' => $next_arrow));
        if (is_array($pages)) {
            $paged = get_query_var('paged') == 0 ? 1 : get_query_var('paged');
            echo '<div class="preview"><div class="cont text-center"><div class="pagination"><ul class="pagination">';
            foreach ($pages as $page) {
                echo "<li>{$page}</li>";
            }
            echo '</ul></div></div><div class="clear">&nbsp;</div></div>	';
        }
    }
}
开发者ID:alexandruspataru,项目名称:Starter,代码行数:28,代码来源:actions.php

示例10: synchronize

 /**
  * Since we don't always have access to the params passed to BP_Groups_Template
  * we have to wait until after constructor has run to fill in details
  */
 function synchronize()
 {
     global $bp;
     if (isset($this->params) && array_key_exists('parent_id', $this->params)) {
         /**
          * Fill in requests by parent_id for tree traversal on admin side
          */
         $this->groups = bp_group_hierarchy_get_by_hierarchy($this->params);
         $this->total_group_count = $this->groups['total'];
         $this->groups = $this->groups['groups'];
         $this->group_count = count($this->groups);
         // Re-build pagination links with new group counts
         if ((int) $this->total_group_count && (int) $this->pag_num) {
             $this->pag_links = paginate_links(array('base' => add_query_arg(array('grpage' => '%#%', 'num' => $this->pag_num, 'sortby' => $this->sort_by, 'order' => $this->order)), 'format' => '', 'total' => ceil((int) $this->total_group_count / (int) $this->pag_num), 'current' => $this->pag_page, 'prev_text' => '&larr;', 'next_text' => '&rarr;', 'mid_size' => 1));
         }
     } else {
         if ($this->single_group && $bp->groups->current_group) {
             /**
              * Groups with multi-level slugs are missed by the parent.
              * Fill them in from $bp->groups->current_group
              */
             $this->groups = array((object) array('group_id' => $bp->groups->current_group->id));
             $this->group_count = 1;
         }
     }
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:30,代码来源:bp-group-hierarchy-template.php

示例11: momtaz_loop_pagination

/**
 * Momtaz loop pagination function for paginating loops with multiple posts.  This should be used on archive, blog, and
 * search pages.  It is not for singular views.
 *
 * @since 0.1
 * @access public
 * @uses paginate_links() Creates a string of paginated links based on the arguments given.
 * @param array $args Arguments to customize how the page links are output.
 */
function momtaz_loop_pagination($args = '')
{
    global $wp_query;
    $total = (int) isset($wp_query->max_num_pages) ? $wp_query->max_num_pages : 1;
    $current = (int) get_query_var('paged') ? get_query_var('paged') : 1;
    // Merge the arguments input with the defaults.
    $args = wp_parse_args($args, array('total' => $total, 'current' => $current, 'prev_next' => true, 'prev_text' => __('&laquo; Previous', 'momtaz'), 'next_text' => __('Next &raquo;', 'momtaz'), 'show_all' => false, 'end_size' => 1, 'mid_size' => 1, 'type' => 'plain', 'before' => '<nav class="pagination loop-pagination">', 'after' => '</nav>', 'echo' => true));
    // Allow developers to overwrite the arguments with a filter.
    $args = apply_filters('momtaz_loop_pagination_args', $args);
    // If there's not more than one page, return nothing.
    if ($args['total'] < 2) {
        return;
    }
    // Don't allow the user to set this to an array.
    if ('array' === $args['type']) {
        $args['type'] = 'plain';
    }
    // Get the paginated links.
    $page_links = apply_filters('momtaz_loop_pagination', paginate_links($args), $args);
    // Wrap the paginated links with the $before and $after elements.
    if (!empty($page_links)) {
        $page_links = $args['before'] . $page_links . $args['after'];
    }
    // Return the paginated links for use in themes.
    if (!$args['echo']) {
        return $page_links;
    }
    echo $page_links;
}
开发者ID:mastinoz,项目名称:Momtaz-Framework,代码行数:38,代码来源:loop-pagination.php

示例12: kad_wp_pagenavi

function kad_wp_pagenavi()
{
    global $wp_query, $wp_rewrite;
    $pages = '';
    $max = $wp_query->max_num_pages;
    if (!($current = get_query_var('paged'))) {
        $current = 1;
    }
    $args['base'] = str_replace(999999999, '%#%', get_pagenum_link(999999999));
    $args['total'] = $max;
    $args['current'] = $current;
    $total = 1;
    $args['mid_size'] = 3;
    $args['end_size'] = 1;
    $args['prev_text'] = '&laquo;';
    $args['next_text'] = '&raquo';
    if ($max > 1) {
        echo '<div class="wp-pagenavi">';
    }
    if ($total == 1 && $max > 1) {
        echo paginate_links($args);
    }
    if ($max > 1) {
        echo '</div>';
    }
}
开发者ID:Joaquinsemp,项目名称:patriestausado,代码行数:26,代码来源:custom.php

示例13: render_frontend

 public function render_frontend($widget_args, $content = '', $context = '')
 {
     $gravityview_view = GravityView_View::getInstance();
     if (!$this->pre_render_frontend()) {
         return;
     }
     $page_size = $gravityview_view->paging['page_size'];
     $total = $gravityview_view->total_entries;
     $atts = shortcode_atts(array('show_all' => !empty($this->settings['show_all']['default'])), $widget_args, 'gravityview_widget_page_links');
     // displaying info
     $curr_page = empty($_GET['pagenum']) ? 1 : intval($_GET['pagenum']);
     $page_link_args = array('base' => add_query_arg('pagenum', '%#%', gv_directory_link()), 'format' => '&pagenum=%#%', 'add_args' => array(), 'prev_text' => '&laquo;', 'next_text' => '&raquo;', 'type' => 'list', 'end_size' => 1, 'mid_size' => 2, 'total' => empty($page_size) ? 0 : ceil($total / $page_size), 'current' => $curr_page, 'show_all' => !empty($atts['show_all']));
     /**
      * @filter `gravityview_page_links_args` Filter the pagination options
      * @since 1.1.4
      * @param array  $page_link_args Array of arguments for the `paginate_links()` function. [Read more about `paginate_links()`](http://developer.wordpress.org/reference/functions/paginate_links/)
      */
     $page_link_args = apply_filters('gravityview_page_links_args', $page_link_args);
     $page_links = paginate_links($page_link_args);
     if (!empty($page_links)) {
         $class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : '';
         $class = gravityview_sanitize_html_class($class);
         echo '<div class="gv-widget-page-links ' . $class . '">' . $page_links . '</div>';
     } else {
         do_action('gravityview_log_debug', 'GravityView_Widget_Page_Links[render_frontend] No page links; paginate_links() returned empty response.');
     }
 }
开发者ID:mgratch,项目名称:GravityView,代码行数:27,代码来源:class-gravityview-widget-page-links.php

示例14: wp_smart_pagination

	function wp_smart_pagination() {
		global $wp_query;
		
		echo '<div class="wp-smart-pagination">';
		echo '<div class="wpsp-page-nav">';
		$big = 999999999; // need an unlikely integer
		
		echo paginate_links( array(
			'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
			'format' => '?paged=%#%',
			'current' => max( 1, get_query_var('paged') ),
			'total' => $wp_query->max_num_pages
		) ); ?>
		</div><!-- /.wpsp-page-nav -->
		
		<form class="wpsp-page-nav-form" action="<?php echo $_SERVER['REQUEST_URI'];?>" method="get">
			<label for="sortby" class="wpsp-label wpsp-hidden"><?php _e('Go to', 'wp-smart-pagination'); ?></label>
			<input class="wpsp-input-number" type="text" placeholder="Jump to" size="6" name="paged" />
			<input class="wpsp-button" value="Go" type="submit" > 
		</form>
		
		</div><!-- /.wp-smart-pagination -->
	
<?php	
	
	}
开发者ID:johnmanlove,项目名称:Bridgeland,代码行数:26,代码来源:wp-smart-pagination.php

示例15: digitalstore_pagination

/**
 * Pagination
 *
 * Echoes the pagination for the theme.
 *
 * @return   string
 * @access   private
 * @since    1.0
*/
function digitalstore_pagination($range = 4, $return = false, $_wp_query = null)
{
    global $paged, $wp_query, $wp_rewrite;
    $wpq = $_wp_query ? $_wp_query : $wp_query;
    $max_page = $wpq->max_num_pages;
    $paged = $paged ? $paged : 1;
    $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : ($current = 1);
    $out = '<p class="digitalstore-pagination">';
    $pages_text = sprintf(__('Page %d of %d', 'edd-digitalstore'), number_format_i18n($paged), number_format_i18n($max_page));
    $out .= '<span class="pages">' . $pages_text . '</span>';
    $pagination = array('base' => esc_url(add_query_arg('paged', '%#%')), 'format' => '', 'total' => $wp_query->max_num_pages, 'current' => $current, 'end_size' => $range, 'prev_text' => __('&laquo;', 'edd-digitalstore'), 'next_text' => __('&raquo;', 'edd-digitalstore'), 'type' => 'plain');
    if ($wp_rewrite->using_permalinks()) {
        $base_url = get_pagenum_link(1);
        if (is_search()) {
            $base_url = preg_replace('/\\?.*/', '', $base_url);
        }
        $pagination['base'] = user_trailingslashit(trailingslashit(esc_url(remove_query_arg(array('s'), $base_url))) . 'page/%#%/', 'paged');
    }
    if (!empty($wp_query->query_vars['s'])) {
        $pagination['add_args'] = array('s' => get_query_var('s'));
    }
    $out .= paginate_links($pagination);
    $out .= '</p>';
    if ($return) {
        return $out;
    } else {
        echo $out;
    }
}
开发者ID:SelaInc,项目名称:Digital-Store,代码行数:38,代码来源:pagination.php


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