コード例 #1
1
ファイル: functions.php プロジェクト: king199025/Fox-Kids
function wp_corenavi()
{
    global $wp_query;
    $pages = '';
    $max = $wp_query->max_num_pages;
    if (!($current = get_query_var('paged'))) {
        $current = 1;
    }
    $a['base'] = str_replace(999999999, '%#%', get_pagenum_link(999999999));
    $a['total'] = $max;
    $a['current'] = $current;
    $total = 1;
    //1 - выводить текст "Страница N из N", 0 - не выводить
    $a['mid_size'] = 3;
    //сколько ссылок показывать слева и справа от текущей
    $a['end_size'] = 1;
    //сколько ссылок показывать в начале и в конце
    $a['prev_text'] = '«';
    //текст ссылки "Предыдущая страница"
    $a['next_text'] = '»';
    //текст ссылки "Следующая страница"
    if ($max > 1) {
        echo '<div class="navigation">';
    }
    if ($total == 1 && $max > 1) {
        $pages = '<span class="pages">Страница ' . $current . ' из ' . $max . '</span>' . "\r\n";
    }
    echo $pages . paginate_links($a);
    if ($max > 1) {
        echo '</div>';
    }
}
コード例 #2
1
ファイル: pagination.php プロジェクト: madeloa/holmesdev
function page_navi($before = '', $after = '')
{
    global $wpdb, $wp_query;
    $request = $wp_query->request;
    $posts_per_page = intval(get_query_var('posts_per_page'));
    $paged = intval(get_query_var('paged'));
    $numposts = $wp_query->found_posts;
    $max_page = $wp_query->max_num_pages;
    if ($numposts <= $posts_per_page) {
        return;
    }
    if (empty($paged) || $paged == 0) {
        $paged = 1;
    }
    $pages_to_show = 3;
    $pages_to_show_minus_1 = $pages_to_show - 1;
    $half_page_start = floor($pages_to_show_minus_1 / 2);
    $half_page_end = ceil($pages_to_show_minus_1 / 2);
    $start_page = $paged - $half_page_start;
    if ($start_page <= 0) {
        $start_page = 1;
    }
    $end_page = $paged + $half_page_end;
    if ($end_page - $start_page != $pages_to_show_minus_1) {
        $end_page = $start_page + $pages_to_show_minus_1;
    }
    if ($end_page > $max_page) {
        $start_page = $max_page - $pages_to_show_minus_1;
        $end_page = $max_page;
    }
    if ($start_page <= 0) {
        $start_page = 1;
    }
    echo $before . '<div class="pagination_wrapper"><ul class="pagination">' . "";
    if ($paged > 1) {
        $first_page_text = "First";
        echo '<li class="prev"><a href="' . get_pagenum_link() . '" title="First">' . $first_page_text . '</a></li>';
    }
    $prevposts = get_previous_posts_link('Prev');
    if ($prevposts) {
        echo '<li>' . $prevposts . '</li>';
    } else {
        echo '<li class="disabled"><a href="#">Prev</a></li>';
    }
    for ($i = $start_page; $i <= $end_page; $i++) {
        if ($i == $paged) {
            echo '<li class="active"><a href="#">' . $i . '</a></li>';
        } else {
            echo '<li><a href="' . get_pagenum_link($i) . '">' . $i . '</a></li>';
        }
    }
    if ($end_page < $max_page) {
        $last_page_text = $max_page;
        echo '<li class="next"><a href="' . get_pagenum_link($max_page) . '" title="Last">' . $last_page_text . '</a></li>';
    }
    echo '<li class="">';
    next_posts_link('Next');
    echo '</li>';
    echo '</ul></div>' . $after . "";
}
コード例 #3
1
ファイル: template-tags.php プロジェクト: abcode619/wpstuff
    /**
     * 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 
        }
    }
コード例 #4
0
    function createPagination($query)
    {
        global $wp_rewrite;
        $total = $query->max_num_pages;
        $current = max(1, ThemeHelper::getPageNumber());
        $Validation = new ThemeValidation();
        $pagination = array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'current' => $current, 'total' => $total, 'next_text' => __(' >', THEME_CONTEXT), 'prev_text' => __('< ', THEME_CONTEXT));
        if ($wp_rewrite->using_permalinks()) {
            $pagination['base'] = user_trailingslashit(trailingslashit(remove_query_arg('s', get_pagenum_link(1))) . 'page/%#%/', 'paged');
        }
        if (is_search()) {
            $pagination['add_args'] = array('s' => urlencode(get_query_var('s')));
        }
        $html = paginate_links($pagination);
        if ($Validation->isNotEmpty($html)) {
            $html = '
				<div class="theme-blog-pagination-box">
					<div class="theme-blog-pagination">
						' . $html . '
					</div>
				</div>
			';
        }
        return $html;
    }
    /**
     * Display navigation to next/previous set of posts when applicable.
     */
    function wpmaterialdesign_paging_nav()
    {
        // Don't print empty markup if there's only one page.
        if ($GLOBALS['wp_query']->max_num_pages < 2) {
            return;
        }
        ?>
	<nav class="navigation paging-navigation" role="navigation">

			<?php 
        global $wp_query;
        $big = 999999999;
        // need an unlikely integer
        $pages = 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, 'type' => 'array'));
        if (is_array($pages)) {
            $paged = get_query_var('paged') == 0 ? 1 : get_query_var('paged');
            echo '<div class="pagination-wrap"><ul class="pagination">';
            foreach ($pages as $page) {
                echo "<li>{$page}</li>";
            }
            echo '</ul></div>';
        }
        ?>

	<!-- .nav-links -->
	</nav><!-- .navigation -->
	<?php 
    }
コード例 #6
0
ファイル: utils.php プロジェクト: ChuanGz/Source_web
function novavideo_lite_paginate()
{
    $big = 999999999;
    // need an unlikely integer
    global $wp_query;
    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));
}
コード例 #7
0
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 
    }
}
コード例 #8
0
ファイル: templates.php プロジェクト: alvarpoon/get-it-write
 function gazeta_the_posts_pagination($query, $echo = true)
 {
     $pagination = '';
     global $wp_query;
     if (empty($query)) {
         $query = $wp_query;
     }
     if ($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=%#%';
     $args = array('base' => $pagenum_link, 'format' => $format, 'total' => $query->max_num_pages, 'current' => $paged, 'mid_size' => 3, 'type' => 'list', 'add_args' => array_map('urlencode', $query_args), 'prev_text' => '<i class="fa fa-angle-double-left"></i>', 'next_text' => '<i class="fa fa-angle-double-right"></i>', 'before_page_number' => '<span>', 'after_page_number' => '</span>');
     // Set up paginated links.
     $pagination = paginate_links(apply_filters('gazeta_old_navigation_args', $args));
     if ($pagination) {
         if ($echo === false) {
             return '<nav class="navigation pagination"><div class="nav-links">' . $pagination . '</div></nav>';
         } else {
             echo '<nav class="navigation pagination"><div class="nav-links">';
             echo $pagination;
             echo '</div></nav>';
         }
     }
 }
コード例 #9
0
	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	
	
	}
コード例 #10
0
ファイル: pagination.php プロジェクト: SelaInc/Digital-Store
/**
 * 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;
    }
}
コード例 #11
0
function virtue_wp_pagenav()
{
    global $wp_query, $wp_rewrite;
    $pages = '';
    $big = 999999999;
    // need an unlikely integer
    $max = $wp_query->max_num_pages;
    if (!($current = get_query_var('paged'))) {
        $current = 1;
    }
    $args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big)));
    $args['total'] = $max;
    $args['current'] = $current;
    $args['add_args'] = false;
    $total = 1;
    $args['mid_size'] = 3;
    $args['end_size'] = 1;
    $args['prev_text'] = '«';
    $args['next_text'] = '»';
    if ($max > 1) {
        echo '<div class="wp-pagenavi">';
    }
    if ($total == 1 && $max > 1) {
        echo paginate_links($args);
    }
    if ($max > 1) {
        echo '</div>';
    }
}
コード例 #12
0
ファイル: template-tags.php プロジェクト: de190909/WPTest
 function flatbook_post_pagination($pages = '', $range = 8)
 {
     $showitems = $range * 2 + 1;
     global $paged;
     if (empty($paged)) {
         $paged = 1;
     }
     if ($pages == '') {
         global $wp_query;
         $pages = $wp_query->max_num_pages;
         if (!$pages) {
             $pages = 1;
         }
     }
     if (1 != $pages) {
         echo '<nav class="blog-pagination">';
         echo '<ul class="pagination">';
         for ($i = 1; $i <= $pages; $i++) {
             if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems)) {
                 echo $paged == $i ? '<li class="active"><span class="page-number current">' . $i . '</span></li>' : '<li><a href="' . esc_url(get_pagenum_link($i)) . '" class="page-number inactive" >' . $i . '</a></li>';
             }
         }
         echo '</ul>';
         $paged = get_query_var('paged') ? get_query_var('paged') : 1;
         echo '<p class="page-indicator">';
         printf(__('Page %1$s of %2$s', 'flatbook'), $paged, $wp_query->max_num_pages);
         echo '</p>';
         echo '</nav>';
     }
 }
コード例 #13
0
ファイル: pagination.php プロジェクト: arrezende/promillus
 function mp_core_paginate_links($args = array())
 {
     global $wp_query;
     if (get_query_var('paged')) {
         $current_page = get_query_var('paged');
     } else {
         if (get_query_var('page')) {
             $current_page = get_query_var('page');
         } else {
             $current_page = 1;
         }
     }
     $permalink_structure = get_option('permalink_structure');
     $format = empty($permalink_structure) ? '?page=%#%' : 'page/%#%/';
     //Split the current url at the question mark
     $url_args = explode('?', $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
     //If there is a question mark, store everything after it in url_args with a question mark
     $url_args = isset($url_args[1]) ? '?' . $url_args[1] : NULL;
     //This array stores all of the args (eg: ?s=MyTestSearch) that could be in the url. You can add your own using the filter 'mp_core_pagination_arg_remover'
     $array_of_url_args_to_remove = apply_filters('mp_core_pagination_arg_remover', array('s'));
     $defaults = array('total' => $wp_query->max_num_pages, 'base' => mp_core_remove_query_arg($array_of_url_args_to_remove, html_entity_decode(get_pagenum_link(1))) . '%_%' . $url_args, 'format' => $format, 'current' => $current_page, 'prev_next' => true, 'prev_text' => apply_filters('mp_core_pagination_prev', '<'), 'next_text' => apply_filters('mp_core_pagination_prev', '>'), 'type' => 'list', 'show_all' => false);
     $args = wp_parse_args($args, $defaults);
     echo '<nav id="posts-navigation" class="row pagination mp-core-pagination">';
     echo paginate_links(apply_filters('mp_core_pagination', $args));
     echo '</nav>';
 }
コード例 #14
0
ファイル: functions.php プロジェクト: KaiYangCHN/WordPress
function pagenav($query_string)
{
    global $posts_per_page, $paged;
    $my_query = new WP_Query($query_string . "&posts_per_page=-1");
    $total_posts = $my_query->post_count;
    if (empty($paged)) {
        $paged = 1;
    }
    $prev = $paged - 1;
    $next = $paged + 1;
    $range = 4;
    // only edit this if you want to show more page-links
    $showitems = $range * 2 + 1;
    $pages = ceil($total_posts / $posts_per_page);
    if (1 != $pages) {
        echo "<div class='pagination'>";
        echo $paged > 2 && $paged + $range + 1 > $pages && $showitems < $pages ? "<a href='" . get_pagenum_link(1) . "'>最前</a>" : "";
        echo $paged > 1 && $showitems < $pages ? "<a href='" . get_pagenum_link($prev) . "'>上一页</a>" : "";
        for ($i = 1; $i <= $pages; $i++) {
            if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems)) {
                echo $paged == $i ? "<span class='current'>" . $i . "</span>" : "<a href='" . get_pagenum_link($i) . "' class='inactive' >" . $i . "</a>";
            }
        }
        echo $paged < $pages && $showitems < $pages ? "<a href='" . get_pagenum_link($next) . "'>下一页</a>" : "";
        echo $paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages ? "<a href='" . get_pagenum_link($pages) . "'>最后</a>" : "";
        echo "</div>\n";
    }
}
コード例 #15
0
function optimizer_pagination($navigation = 'numbered', $query = '')
{
    ?>
		<?php 
    if ($navigation !== 'no_nav') {
        ?>
				<?php 
        if ($navigation == 'numbered' || $navigation == 'numbered_ajax') {
            ?>
					<div class="ast_pagenav">
                        <?php 
            if ($query == '') {
                global $wp_query;
                $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, 'show_all' => true, 'prev_next' => false, 'add_args' => false));
            } else {
                if ($query !== '') {
                    $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' => $query->max_num_pages, 'show_all' => true, 'prev_next' => false, 'add_args' => false));
                }
            }
            ?>
                    </div>
                <?php 
        }
        ?>
        <?php 
    }
}
コード例 #16
0
ファイル: custom_functions.php プロジェクト: bulats/chef
 function themefusion_pagination($pages = '', $range = 2)
 {
     global $data;
     $showitems = $range * 2 + 1;
     global $paged;
     if (empty($paged)) {
         $paged = 1;
     }
     if ($pages == '') {
         global $wp_query;
         $pages = $wp_query->max_num_pages;
         if (!$pages) {
             $pages = 1;
         }
     }
     if (1 != $pages) {
         echo "<div class='pagination clearfix'>";
         //if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'><span class='arrows'>&laquo;</span> First</a>";
         if ($paged > 1) {
             echo "<a class='pagination-prev' href='" . get_pagenum_link($paged - 1) . "'><span class='page-prev'></span>" . __('Previous', 'Avada') . "</a>";
         }
         for ($i = 1; $i <= $pages; $i++) {
             if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems)) {
                 echo $paged == $i ? "<span class='current'>" . $i . "</span>" : "<a href='" . get_pagenum_link($i) . "' class='inactive' >" . $i . "</a>";
             }
         }
         if ($paged < $pages) {
             echo "<a class='pagination-next' href='" . get_pagenum_link($paged + 1) . "'>" . __('Next', 'Avada') . "<span class='page-next'></span></a>";
         }
         //if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last <span class='arrows'>&raquo;</span></a>";
         echo "</div>\n";
     }
 }
コード例 #17
0
 protected function setup()
 {
     // the boring defaults that are ommited in the wpgrade-config.php
     // configuration for clarity and bravity, and also because some require
     // extensive logic handling
     $defaults = array('base' => str_replace(999999999, '%#%', esc_url(get_pagenum_link(999999999))), 'format' => $this->pager_format($this->pager), 'current' => max(1, get_query_var($this->pager)), 'total' => $this->query->max_num_pages, 'formatter' => null, 'prev_next' => true, 'sorted_paging' => false, 'order' => 'desc', 'show_all' => false, 'end_size' => 1, 'mid_size' => 2, 'add_args' => false, 'add_fragment' => null);
     $conf = wpgrade::merge($defaults, $this->conf);
     # we're filling in prev_text and next_text seperatly to avoid
     # requesting the translation when not required
     if (empty($conf['prev_text'])) {
         $conf['prev_text'] = __('&laquo; Previous', 'rosa_txtd');
     } else {
         // exists; translate
         $conf['prev_text'] = __($conf['prev_text'], 'rosa_txtd');
     }
     if (empty($conf['next_text'])) {
         $conf['next_text'] = __('Next &raquo;', 'rosa_txtd');
     } else {
         // exists; translate
         $conf['next_text'] = __($conf['next_text'], 'rosa_txtd');
     }
     // is the pager sorted?
     if ($conf['sorted_paging'] && $conf['order'] == 'asc') {
         $temp = $conf['prev_text'];
         $conf['prev_text'] = $conf['next_text'];
         $conf['next_text'] = $temp;
     }
     return $conf;
 }
コード例 #18
0
ファイル: custom.php プロジェクト: Joaquinsemp/patriestausado
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>';
    }
}
コード例 #19
0
ファイル: pagination.php プロジェクト: pcco/portal-redesign
    function pagination($pages = '', $range = 4)
    {
        // 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' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('<i class="fa fa-angle-left"></i>', 'crunchpress'), 'next_text' => __('<i class="fa fa-angle-right"></i>', 'crunchpress')));
        if ($links) {
            ?>
			<div class="pagination-all pagination" role="navigation">
				<ul id='pagination'>
					<li>
						<?php 
            echo $links;
            ?>
					</li>
				</ul><!-- .pagination -->
			</div><!-- .navigation -->
			<?php 
        }
    }
コード例 #20
0
ファイル: actions.php プロジェクト: alexandruspataru/Starter
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>	';
        }
    }
}
コード例 #21
0
ファイル: pagination.php プロジェクト: pixelstorm/pagination
    function ml_pagination()
    {
        ?>

<?php 
        $prev_arrow = is_rtl() ? '
    
    <span class = "icon more_icon">' : '<span class = "icon previous_icon">';
        $next_arrow = is_rtl() ? '
    
    <span class = "icon more_icon">' : '<span class = "icon more_icon">';
        global $wp_query;
        $total = $wp_query->max_num_pages;
        $big = 999999999;
        // need an unlikely integer
        if ($total > 1) {
            ?>


  <h6>Browse the Archives:</h6>


<?php 
            if (!($current_page = get_query_var('paged'))) {
                $current_page = 1;
            }
            if (get_option('permalink_structure')) {
                $format = 'page/%#%/';
            } else {
                $format = '&paged=%#%';
            }
            echo 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' => 3, 'type' => 'list', 'prev_text' => $prev_arrow, 'next_text' => $next_arrow));
        }
    }
コード例 #22
0
ファイル: helper.php プロジェクト: mattmcgiv/etp-almera-theme
 public static function pagenavi($query = null)
 {
     global $wp_query, $wp_rewrite;
     if (!$query) {
         $query = $wp_query;
     }
     $pages = '';
     $max = $query->max_num_pages;
     if (!($current = get_query_var('paged'))) {
         $current = 1;
     }
     $a['base'] = str_replace(999999999, '%#%', get_pagenum_link(999999999));
     $a['total'] = $max;
     $a['current'] = $current;
     $total = 1;
     //1 - display the text "Page N of N", 0 - not display
     $a['mid_size'] = 5;
     //how many links to show on the left and right of the current
     $a['end_size'] = 1;
     //how many links to show in the beginning and end
     $a['prev_text'] = '';
     //text of the "Previous page" link
     $a['next_text'] = '';
     //text of the "Next page" link
     echo $pages . paginate_links($a);
 }
コード例 #23
0
 public function pagination($total = -1, $spread = -1)
 {
     global $wp_query;
     $big = 999999999;
     // need an unlikely integer
     $current = max(1, get_query_var('paged'));
     if ($total < 1) {
         $total = $wp_query->max_num_pages;
     }
     if ($spread < 1) {
         $spread = self::DEFAULT_PAGINATION_SPREAD;
     }
     $spread_left = min($current - 1, $spread * 2);
     $spread_right = min($current + $spread * 2, $total) - $current;
     if ($spread_left + $spread_right > 4) {
         if ($spread_left >= 2 && $spread_right >= 2) {
             $spread_left = $spread_right = 2;
         } elseif ($spread_left < 2) {
             $spread_right = 4 - $spread_left;
         } else {
             $spread_left = 4 - $spread_right;
         }
     }
     $pages = range($current - $spread_left, $current + $spread_right);
     $links = array_map(function ($n) use($current) {
         return '<li>' . ($n == $current ? "<span>{$current}</span>" : sprintf('<a href="%s">%s</a>', get_pagenum_link($n), $n)) . '</li>';
     }, $pages);
     $out = '<nav class="pagination">';
     $out .= sprintf('<a class="edge edge--left" href="%s">First</a>', get_pagenum_link(1));
     $out .= sprintf('<ul class="nav-menu">%s</ul>', implode('', $links));
     $out .= sprintf('<a class="edge edge--right" href="%s">Last</a>', get_pagenum_link($total));
     $out = '</nav>';
     return $out;
 }
コード例 #24
0
ファイル: functions.php プロジェクト: GitGump/Purity
function pagination($query_string)
{
    global $posts_per_page, $paged;
    $my_query = new WP_Query($query_string . "&posts_per_page=-1");
    $total_posts = $my_query->post_count;
    if (empty($paged)) {
        $paged = 1;
    }
    $prev = $paged - 1;
    $next = $paged + 1;
    $range = 1;
    // only edit this if you want to show more page-links
    $showitems = $range * 2 + 1;
    $pages = ceil($total_posts / $posts_per_page);
    if (1 != $pages) {
        echo "<ul class='pure-paginator'>";
        echo "<li><a class='pure-button prev' href='" . get_pagenum_link(1) . "'>&#171;</a></li>";
        echo $paged > 1 && $showitems < $pages ? "<li><a class='pure-button prev' href='" . get_pagenum_link($prev) . "'>&#8249;</a></li>" : "";
        for ($i = 1; $i <= $pages; $i++) {
            if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems)) {
                echo $paged == $i ? "<li><a class='pure-button pure-button-active' href='" . get_pagenum_link($i) . "'>" . $i . "</a></li>" : "<li><a class='pure-button' href='" . get_pagenum_link($i) . "'>" . $i . "</a></li>";
            }
        }
        echo $paged < $pages && $showitems < $pages ? "<li><a class='pure-button next' href='" . get_pagenum_link($next) . "'>&#8250;</a></li>" : "";
        echo "<li><a class='pure-button next' href='" . get_pagenum_link($pages) . "'>&#187;</a></li>";
        echo "</ul>\n";
    }
}
コード例 #25
0
ファイル: functions.php プロジェクト: mfalkus/falcon
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>';
}
コード例 #26
0
ファイル: extras.php プロジェクト: alvarpoon/aeg
function custom_pagination($numpages = '', $pagerange = '', $paged = '')
{
    if (empty($pagerange)) {
        $pagerange = 2;
    }
    global $paged;
    if (empty($paged)) {
        $paged = 1;
    }
    if ($numpages == '') {
        global $wp_query;
        $numpages = $wp_query->max_num_pages;
        if (!$numpages) {
            $numpages = 1;
        }
    }
    $uri_parts = explode('?', $_SERVER['REQUEST_URI'], 2);
    $split_parameters = explode('&', $uri_parts[1]);
    for ($i = 0; $i < count($split_parameters); $i++) {
        $final_split = explode('=', $split_parameters[$i]);
        $split_complete[$final_split[0]] = $final_split[1];
    }
    $pagination_args = array('base' => preg_replace('/\\?.*/', '', get_pagenum_link(1)) . '%_%', 'format' => 'page/%#%', 'total' => $numpages, 'current' => $paged, 'show_all' => False, 'end_size' => 1, 'mid_size' => $pagerange, 'prev_next' => True, 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'type' => 'plain', 'add_args' => $split_complete, 'add_fragment' => '');
    $paginate_links = paginate_links($pagination_args);
    if ($paginate_links) {
        echo "<div class='pagination_bar_container'>";
        echo "<div class='pagination_bar clearfix'>";
        echo $paginate_links;
        echo "</div>";
        echo "</div>";
    }
}
コード例 #27
0
    /**
     * 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 
        }
    }
コード例 #28
0
    /**
     * Display navigation to next/previous set of posts when applicable.
     *
     * @since Anciela 1.0
     */
    function anciela_paging_nav($query = null)
    {
        // Don't print empty markup if there's only one page.
        if ($query == null) {
            $query = $GLOBALS['wp_query'];
        }
        if ($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' => $query->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('&larr; Plus récents', 'anciela'), 'next_text' => __('Plus anciens &rarr;', 'anciela')));
        if ($links) {
            ?>
	<nav class="navigation paging-navigation" role="navigation">
        <?php 
            echo $links;
            ?>
	</nav><!-- .navigation -->
	<?php 
        }
    }
コード例 #29
0
/**
 * 分頁.
 */
function wp_pagenavi()
{
    global $wp_query;
    $_obj_post_count = wp_count_posts();
    $max = ceil($_obj_post_count->publish / 6);
    if (!($current = get_query_var('paged'))) {
        $current = 1;
    }
    $args['base'] = str_replace(999999999, '%#%', get_pagenum_link(999999999));
    $args['total'] = $max;
    $args['current'] = $current;
    $args['type'] = 'array';
    $args['prev_text'] = '<';
    $args['next_text'] = '>';
    $_arr_pages = paginate_links($args);
    $_str_page = '<nav>';
    $_str_page .= '<ul class="pagination">';
    $_str_page .= '<li class="disabled"><a href="#">共' . $max . '頁</a></li>';
    foreach ($_arr_pages as $key => $val) {
        if (substr($val, 0, 2) == '<s') {
            $_str_page .= '<li class="active">' . $val . '</li>';
        } else {
            $_str_page .= '<li>' . $val . '</li>';
        }
    }
    $_str_page .= '</ul>';
    $_str_page .= '</nav>';
    echo $_str_page;
}
コード例 #30
0
ファイル: pagination.php プロジェクト: sergey-h/naman2
 function wpex_pagination($custom_query = '')
 {
     // Arrows with RTL support
     $prev_arrow = is_rtl() ? 'fa fa-angle-right' : 'fa fa-angle-left';
     $next_arrow = is_rtl() ? 'fa fa-angle-left' : 'fa fa-angle-right';
     // Get vars
     if ($custom_query) {
         $query = $custom_query;
     } else {
         global $wp_query;
         $query = $wp_query;
     }
     $total = $query->max_num_pages;
     $big = 999999999;
     // Display pagination
     if ($total > 1) {
         if (!($current_page = get_query_var('paged'))) {
             $current_page = 1;
         }
         if (get_option('permalink_structure')) {
             $format = 'page/%#%/';
         } else {
             $format = '&paged=%#%';
         }
         echo 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' => 3, 'type' => 'list', 'prev_text' => '<i class="' . $prev_arrow . '"></i>', 'next_text' => '<i class="' . $next_arrow . '"></i>'));
     }
 }