function woo_pagenav($custom_query = '') { global $woo_options, $wp_query, $paged, $page; // Set query max pages $max_pages = 1; if ('' != $custom_query) { $max_pages = $custom_query->max_num_pages; } else { $max_pages = $wp_query->max_num_pages; } // If the user has set the option to use simple paging links, display those. By default, display the pagination. if (@$woo_options['woo_pagination_type'] == 'simple') { if (get_next_posts_link('', $max_pages) || get_previous_posts_link()) { ?> <div class="nav-entries"> <?php next_posts_link('<span class="nav-prev fl"><i class="icon-angle-left"></i> ' . __('Older posts', 'woothemes') . '</span>', $max_pages); ?> <?php previous_posts_link('<span class="nav-next fr">' . __('Newer posts', 'woothemes') . ' <i class="icon-angle-right"></i></span>'); ?> <div class="fix"></div> </div> <?php } // End IF Statement } else { woo_pagination(array(), $custom_query); } // End IF Statement }
/** * Display navigation to next/previous set of posts when applicable. * * @todo Remove this function when WordPress 4.3 is released. */ function cleanblog_posts_navigation() { // Don't print empty markup if there's only one page. if ($GLOBALS['wp_query']->max_num_pages < 2) { return; } ?> <ul class="pager"> <?php if (get_next_posts_link()) { ?> <li class="next"><?php next_posts_link(esc_html__('Older posts', 'cleanblog')); ?> </li> <?php } ?> <?php if (get_previous_posts_link()) { ?> <li class="previous"><?php previous_posts_link(esc_html__('Newer posts', 'cleanblog')); ?> </li> <?php } ?> </ul> <?php }
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 . ""; }
function nice_pagenavi() { if (function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?> <?php if (get_next_posts_link() || get_previous_posts_link()) { ?> <nav class="nav-entries"> <?php next_posts_link('<div class="nav-prev fl">' . __('Older posts', 'nicethemes') . '</div>'); ?> <?php previous_posts_link('<div class="nav-next fr">' . __('Newer posts', 'nicethemes') . '</div>'); ?> <div class="fix"></div> </nav> <?php } ?> <?php } }
/** * Display navigation to next/previous pages when applicable */ function orbit_content_nav($nav_id) { global $wp_query; ?> <nav id="<?php echo $nav_id; ?> "> <ul> <?php if (is_single()) { // navigation links for single posts ?> <li><?php previous_post_link('%link', '' . _x('←', 'Previous post link', 'orbit') . '%title'); ?> </li> <li><?php next_post_link('%link', '%title' . _x('→', 'Next post link', 'orbit') . ''); ?> </li> <?php } elseif ($wp_query->max_num_pages > 1 && (is_home() || is_archive() || is_search())) { // navigation links for home, archive, and search pages ?> <?php if (get_next_posts_link()) { ?> <li><?php next_posts_link(__('← Older posts', 'orbit')); ?> </li> <?php } ?> <?php if (get_previous_posts_link()) { ?> <li><?php previous_posts_link(__('Newer posts →', 'orbit')); ?> </li> <?php } ?> <?php } ?> </ul> </nav><!-- #<?php echo $nav_id; ?> --> <?php }
/** * Display navigation to next/previous set of posts when applicable. * * @return void */ function silencio_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"> <div class="nav-links"> <?php if (get_next_posts_link()) { ?> <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">←</span> Older posts', 'silencio')); ?> </div> <?php } if (get_previous_posts_link()) { ?> <div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">→</span>', 'silencio')); ?> </div> <?php } ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
function page_navigation() { $previous_posts_link = get_previous_posts_link('Vorige'); $next_posts_link = get_next_posts_link('Volgende'); if (!$previous_posts_link && !$next_posts_link) { return; } ?> <div class="col-md-9 text-right"> <ul class="pagination"> <?php if ($previous_posts_link) { printf('<li>%s</li>', $previous_posts_link); } global $wp_query; $max = $wp_query->max_num_pages; $current = get_query_var('paged') ? get_query_var('paged') : 1; printf('<li><a title="Huidige" href="#">%d/%d</a></li>', $current, $max); ?> <?php if ($next_posts_link) { printf('<li>%s</li>', $next_posts_link); } ?> </ul> </div> <?php }
function rel_next_prevlink_tags() { //1ページを複数に分けた分割ページ if (is_single() || is_page()) { global $wp_query; $multipage = check_multi_page(); if ($multipage[0] > 1) { $prev = generate_multipage_url('prev'); $next = generate_multipage_url('next'); if ($prev) { echo '<link rel="prev" href="' . $prev . '" />' . PHP_EOL; } if ($next) { echo '<link rel="next" href="' . $next . '" />' . PHP_EOL; } } } else { //トップページやカテゴリページなどの分割ページの設定 global $paged; if (get_previous_posts_link()) { echo '<link rel="prev" href="' . get_pagenum_link($paged - 1) . '" />' . PHP_EOL; } if (get_next_posts_link()) { echo '<link rel="next" href="' . get_pagenum_link($paged + 1) . '" />' . PHP_EOL; } } }
/** * Adds custom classes to the array of body classes. * * @param array $classes Classes for the body element. * @return array */ function boardwalk_body_classes($classes) { // Adds a class of group-blog to blogs with more than 1 published author. if (is_multi_author()) { $classes[] = 'group-blog'; } if (get_next_posts_link()) { $classes[] = 'next-link'; } if (get_previous_posts_link()) { $classes[] = 'previous-link'; } if (1 == get_theme_mod('boardwalk_filter_featured_images')) { $classes[] = 'filter-on'; } if (1 == get_theme_mod('boardwalk_entry_title')) { $classes[] = 'title-with-content'; } if (1 == get_theme_mod('boardwalk_unfixed_header')) { $classes[] = 'unfixed-header'; } if (is_active_sidebar('sidebar-1') || has_nav_menu('primary')) { $classes[] = 'has-sidebar'; } return $classes; }
public function showHome() { $posts = ChesterWPCoreDataHelpers::getWordpressPostsFromLoop(); $content_block_1 = $this->render('post_previews', array('posts' => $posts, 'next_posts_link' => get_next_posts_link(), 'previous_posts_link' => get_previous_posts_link())); $latestGallery = $this->render('galleries', array('posts' => ChesterWPCoreDataHelpers::getPosts(false, 'gallery', '1', array('location', 'map', 'website')))); echo $this->renderPage('grids/grid_two_column', array('content_block_1' => $content_block_1, 'content_block_2' => $latestGallery)); }
function am_paging_nav() { global $wp_query; // Don't print empty markup if there's only one page. if ($wp_query->max_num_pages < 2) { return; } ?> <nav class="navigation paging-navigation" role="navigation"> <div class="nav-links"> <?php if (get_next_posts_link()) { ?> <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">←</span> Older posts', 'am_sandbox_theme')); ?> </div> <?php } ?> <?php if (get_previous_posts_link()) { ?> <div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">→</span>', 'am_sandbox_theme')); ?> </div> <?php } ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
function woo_pagenav() { global $woo_options; // If the user has set the option to use simple paging links, display those. By default, display the pagination. if (array_key_exists('woo_pagination_type', $woo_options) && $woo_options['woo_pagination_type'] == 'simple') { if (get_next_posts_link() || get_previous_posts_link()) { ?> <div class="nav-entries"> <?php next_posts_link('<span class="nav-prev fl">' . __('<span class="meta-nav">←</span> Older posts', 'woothemes') . '</span>'); ?> <?php previous_posts_link('<span class="nav-next fr">' . __('Newer posts <span class="meta-nav">→</span>', 'woothemes') . '</span>'); ?> <div class="fix"></div> </div> <?php } // ENDIF } else { woo_pagination(); } // ENDIF }
/** * Display navigation to next/previous pages when applicable * * @since Sunspot 1.0 */ function sunspot_content_nav( $nav_id ) { global $wp_query; $nav_class = 'site-navigation paging-navigation'; if ( is_single() ) $nav_class = 'site-navigation post-navigation'; ?> <nav role="navigation" id="<?php echo $nav_id; ?>" class="<?php echo $nav_class; ?>"> <h1 class="assistive-text"><?php _e( 'Post navigation', 'sunspot' ); ?></h1> <?php if ( is_single() ) : // navigation links for single posts ?> <?php previous_post_link( '<div class="nav-previous">%link</div>', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'sunspot' ) . '</span> %title' ); ?> <?php next_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'sunspot' ) . '</span>' ); ?> <?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?> <?php if ( get_next_posts_link() ) : ?> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'sunspot' ) ); ?></div> <?php endif; ?> <?php if ( get_previous_posts_link() ) : ?> <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'sunspot' ) ); ?></div> <?php endif; ?> <?php endif; ?> </nav><!-- #<?php echo $nav_id; ?> --> <?php }
/** * Display navigation to next/previous set of posts when applicable. * * @return void */ function sketch_paging_nav( $max_num_pages = '' ) { // Get max_num_pages if not provided if ( '' == $max_num_pages ) $max_num_pages = $GLOBALS['wp_query']->max_num_pages; // Don't print empty markup if there's only one page. if ( $max_num_pages < 2 ) { return; } ?> <nav class="navigation paging-navigation clear" role="navigation"> <h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'sketch' ); ?></h1> <div class="nav-links"> <?php if ( get_next_posts_link( '', $max_num_pages ) ) : ?> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">Previous</span>', 'sketch' ), $max_num_pages ); ?></div> <?php endif; ?> <?php if ( get_previous_posts_link( '', $max_num_pages ) ) : ?> <div class="nav-next"><?php previous_posts_link( __( '<span class="meta-nav">Next</span>', 'sketch' ), $max_num_pages ); ?></div> <?php endif; ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
/** * Display navigation to newer set of posts when applicable. */ function cinnamon_paging_nav_newer() { // Don't print empty markup if there's only one page. if ($GLOBALS['wp_query']->max_num_pages < 2) { return; } ?> <?php if (get_previous_posts_link()) { ?> <nav class="navigation paging-navigation newer" role="navigation"> <h1 class="screen-reader-text"><?php _e('Posts navigation', 'cinnamon'); ?> </h1> <div class="nav-links"> <div class="nav-next"><?php previous_posts_link(__('Newer stories', 'cinnamon')); ?> </div> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php } ?> <?php }
public static function get_the_posts_navigation($args = array()) { $navigation = ''; if ($GLOBALS['wp_query']->max_num_pages > 1) { $args = wp_parse_args($args, array('prev_text' => __('Older posts', 'wp-starter-theme'), 'next_text' => __('Newer posts', 'wp-starter-theme'), 'screen_reader_text' => __('Posts navigation', 'wp-starter-theme'), 'aligned' => false)); $prev_class = ''; $next_class = ''; if ($args['aligned']) { $prev_class = ' class="pager-prev"'; $next_class = ' class="pager-next"'; } $next_link = get_previous_posts_link($args['next_text']); $prev_link = get_next_posts_link($args['prev_text']); if ($prev_link || $next_link) { if ($prev_link) { $navigation .= '<li' . $prev_class . '>' . $prev_link . '</li>'; } if ($next_link) { $navigation .= '<li' . $next_class . '>' . $next_link . '</li>'; } $navigation = '<ul class="pager">' . $navigation . '</ul>'; $navigation = _navigation_markup($navigation, 'posts-navigation', $args['screen_reader_text']); } } return $navigation; }
function voidx_post_navigation() { ?> <nav class="nav-posts" role="navigation"> <div class="nav-links"> <?php if (get_previous_posts_link()) { ?> <div class="nav-previous prev-page"> <?php previous_posts_link(__('<span class="nav-arrow">← </span>Previous', 'voidx')); ?> </div> <?php } if (get_next_posts_link()) { ?> <div class="nav-next next-page"> <?php next_posts_link(__('Next<span class="nav-arrow"> →</span>', 'voidx')); ?> </div> <?php } ?> </div> </nav><?php }
/** * Display navigation to next/previous set of posts when applicable. */ function zerif_paging_nav() { echo '<div class="clear"></div>'; ?> <nav class="navigation paging-navigation" role="navigation"> <h1 class="screen-reader-text"><?php _e('Posts navigation', 'zerif'); ?> </h1> <div class="nav-links"> <?php if (get_next_posts_link()) { ?> <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">←</span> Older posts', 'zerif')); ?> </div> <?php } ?> <?php if (get_previous_posts_link()) { ?> <div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">→</span>', 'zerif')); ?> </div> <?php } ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
function hitchcock_archive_navigation() { global $wp_query; if ($wp_query->max_num_pages > 1) { ?> <div class="archive-nav"> <?php if (get_previous_posts_link()) { previous_posts_link('<span class="fa fw fa-angle-left"></span>'); } else { echo '<span class="fa fw fa-angle-left"></span>'; } ?> <span class="sep">/</span> <?php if (get_next_posts_link()) { next_posts_link('<span class="fa fw fa-angle-right"></span>'); } else { echo '<span class="fa fw fa-angle-right"></span>'; } ?> <div class="clear"></div> </div> <!-- /archive-nav--> <?php } }
function wpex_infinite_scroll($pages = '', $range = 4) { wp_enqueue_script('att-infinitescroll-init', WPEX_JS_DIR . '/infinitescroll-init.js', array('jquery', 'wpex-global'), 1.0, true); $output = ''; $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) { $output .= '<div class="infinite-scroll-nav clr">'; $output .= '<div class="alignleft newer-posts">'; $output .= get_previous_posts_link('← ' . __('Newer Posts', 'wpex')); $output .= '</div>'; $output .= '<div class="alignright older-posts">'; $output .= get_next_posts_link(__('Older Posts', 'wpex') . ' →'); $output .= '</div>'; $output .= '</div>'; } echo $output; }
function post_navigation() { echo '<div class="navigation">'; echo ' <div class="next-posts">' . get_next_posts_link('« Older Entries') . '</div>'; echo ' <div class="prev-posts">' . get_previous_posts_link('Newer Entries »') . '</div>'; echo '</div>'; }
function reactor_numeric_posts_nav() { if (is_singular()) { return; } global $wp_query; $paginas = new WP_Query($args); $html = ''; /** Stop execution if there's only 1 page */ if ($paginas->max_num_pages <= 1) { return; } $paged = get_query_var('paged') ? absint(get_query_var('paged')) : 1; $max = intval($paginas->max_num_pages); /** Add current page to the array */ if ($paged >= 1) { $links[] = $paged; } /** Add the pages around the current page to the array */ if ($paged >= 3) { $links[] = $paged - 1; $links[] = $paged - 2; } if ($paged + 2 <= $max) { $links[] = $paged + 2; $links[] = $paged + 1; } echo '<div class="navigation"><ul>' . "\n"; /** Previous Post Link */ if (get_previous_posts_link()) { printf('<li>%s</li>' . "\n", get_previous_posts_link()); } /** Link to first page, plus ellipses if necessary */ if (!in_array(1, $links)) { $class = 1 == $paged ? ' class="active"' : ''; printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link(1)), '1'); if (!in_array(2, $links)) { echo '<li>…</li>'; } } /** Link to current page, plus 2 pages in either direction if necessary */ sort($links); foreach ((array) $links as $link) { $class = $paged == $link ? ' class="active"' : ''; printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link($link)), $link); } /** Link to last page, plus ellipses if necessary */ if (!in_array($max, $links)) { if (!in_array($max - 1, $links)) { echo '<li>…</li>' . "\n"; } $class = $paged == $max ? ' class="active"' : ''; printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link($max)), $max); } /** Next Post Link */ if (get_next_posts_link()) { printf('<li>%s</li>' . "\n", get_next_posts_link()); } echo '</ul></div>' . "\n"; }
/** * Display navigation to next/previous set of posts when applicable. * */ function uncode_posts_navigation() { // Don't print empty markup if there's only one page. if ($GLOBALS['wp_query']->max_num_pages < 2) { return; } $pagination_args = array('prev_next' => false, 'type' => 'array'); $paginate_links = paginate_links($pagination_args); if (is_array($paginate_links)) { $output = "<ul class='pagination'>"; $prev = get_previous_posts_link('<i class="fa fa-angle-left"></i>'); if ($prev !== NULL) { $output .= '<li class="page-prev">' . $prev . '</li>'; } else { $output .= '<li class="page-prev"><span class="btn btn-link btn-icon-left btn-disable-hover"><i class="fa fa-angle-left"></i></span></li>'; } foreach ($paginate_links as $page) { $output .= '<li><span class="btn-container">' . $page . '</span></li>'; } $next = get_next_posts_link('<i class="fa fa-angle-right"></i>'); if ($next !== NULL) { $output .= '<li class="page-next">' . $next . '</li>'; } else { $output .= '<li class="page-next"><span class="btn btn-link btn-icon-right btn-disable-hover"><i class="fa fa-angle-right"></i></span></li>'; } $output .= "</ul><!-- .pagination -->"; } return $output; }
function wpex_infinite_scroll($type = 'standard') { // Load infinite scroll js for standard blog style if ($type == 'standard') { wp_enqueue_script('wpex-infinitescroll', WPEX_JS_DIR_URI . 'infinitescroll-standard.js', array('jquery'), 1.0, true); } // Load infinite scroll js for grid if ($type == 'standard-grid') { wp_enqueue_script('wpex-infinitescroll', WPEX_JS_DIR_URI . 'infinitescroll-standard-grid.js', array('jquery'), 1.0, true); } // Localize loading text $is_params = array('msgText' => __('Loading...', 'wpex')); wp_localize_script('wpex-infinitescroll', 'wpexInfiniteScroll', $is_params); // Output pagination HTML $output = ''; $output .= '<div class="infinite-scroll-nav clr">'; $output .= '<div class="alignleft newer-posts">'; $output .= get_previous_posts_link('← ' . __('Newer Posts', 'wpex')); $output .= '</div>'; $output .= '<div class="alignright older-posts">'; $output .= get_next_posts_link(__('Older Posts', 'wpex') . ' →'); $output .= '</div>'; $output .= '</div>'; echo $output; }
public function posts_link($before = '', $after = '', $args = array(), $query = null) { global $wp_query; if (!$query || !is_a($query, 'WP_Query')) { $query = $wp_query; } // Don't print empty markup if there's only one page. if ($query->max_num_pages < 2) { return; } $args = wp_parse_args($args, array('next_posts_link_label' => null, 'previous_posts_link_label' => null, 'list_class' => '', 'list_item_class' => '')); $output = ''; $next_posts_link = get_next_posts_link($args['next_posts_link_label'], $query->max_num_pages); $prev_posts_link = get_previous_posts_link($args['previous_posts_link_label'], $query->max_num_pages); $list_class = trim($args['list_class']); $list_item_class = trim($args['list_item_class']); if ($next_posts_link || $prev_posts_link) { if (isset($before)) { $output .= $before; } $output .= '<ul' . (!empty($list_class) ? ' class="' . esc_attr($list_class) . '"' : '') . '>'; if ($prev_posts_link) { $output .= '<li class="prev' . (!empty($list_item_class) ? ' ' . esc_attr($list_item_class) : '') . '">' . $prev_posts_link . '</li>'; } if ($next_posts_link) { $output .= '<li class="next' . (!empty($list_item_class) ? ' ' . esc_attr($list_item_class) : '') . '">' . $next_posts_link . '</li>'; } $output .= '</ul>'; if (isset($after)) { $output .= $after; } } return $output; }
/** * Echo archive pagination in page numbers format. * * Applies the `genesis_prev_link_text` and `genesis_next_link_text` filters. * * The links, if needed, are ordered as: * * * previous page arrow, * * first page, * * up to two pages before current page, * * current page, * * up to two pages after the current page, * * last page, * * next page arrow. * * @since 0.2.3 * * @global WP_Query $wp_query Query object. * * @return null Return early if on a single post or page, or only one page present. */ function gmdl_numeric_posts_nav() { if (is_singular()) { return; } global $wp_query; //* Stop execution if there's only 1 page if ($wp_query->max_num_pages <= 1) { return; } $paged = get_query_var('paged') ? absint(get_query_var('paged')) : 1; $max = intval($wp_query->max_num_pages); //* Add current page to the array if ($paged >= 1) { $links[] = $paged; } //* Add the pages around the current page to the array if ($paged >= 3) { $links[] = $paged - 1; $links[] = $paged - 2; } if ($paged + 2 <= $max) { $links[] = $paged + 2; $links[] = $paged + 1; } genesis_markup(array('html5' => '<div %s>', 'xhtml' => '<div class="navigation">', 'context' => 'archive-pagination')); echo '<ul class="mdl-cell mdl-cell--12-col pagination">'; //* Previous Post Link if (get_previous_posts_link()) { printf('<li class="pagination-previous alignleft">%s</li>' . "\n", get_previous_posts_link(apply_filters('genesis_prev_link_text', '<span class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon mdl-color--accent mdl-color-text--white" role="presentation" data-upgraded=",MaterialButton,MaterialRipple"><i class="material-icons">arrow_back</i><span class="mdl-button__ripple-container"><span class="mdl-ripple"></span></span></span>' . __('Previous Page', 'genesis')))); } //* Link to first page, plus ellipses if necessary if (!in_array(1, $links)) { $class = 1 == $paged ? ' class="current"' : ''; printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link(1)), '1'); if (!in_array(2, $links)) { echo '<li class="pagination-omission">…</li>'; } } //* Link to current page, plus 2 pages in either direction if necessary sort($links); foreach ((array) $links as $link) { $class = $paged == $link ? ' class="current"' : ''; printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link($link)), $link); } //* Link to last page, plus ellipses if necessary if (!in_array($max, $links)) { if (!in_array($max - 1, $links)) { echo '<li class="pagination-omission">…</li>' . "\n"; } $class = $paged == $max ? ' class="current"' : ''; printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link($max)), $max); } //* Next Post Link if (get_next_posts_link()) { printf('<li class="pagination-next alignright">%s</li>' . "\n", get_next_posts_link(apply_filters('genesis_next_link_text', __('Next Page', 'genesis') . '<span class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon mdl-color--accent mdl-color-text--white" role="presentation" data-upgraded=",MaterialButton,MaterialRipple"><i class="material-icons">arrow_forward</i><span class="mdl-button__ripple-container"><span class="mdl-ripple"></span></span></span>'))); } echo '</ul></div>' . "\n"; }
/** * Echo archive pagination in page numbers format. * * Applies the `genesis_prev_link_text` and `genesis_next_link_text` filters. * * The links, if needed, are ordered as: * * * previous page arrow, * * first page, * * up to two pages before current page, * * current page, * * up to two pages after the current page, * * last page, * * next page arrow. * * @since 0.2.3 * * @global WP_Query $wp_query Query object. * * @return null Return early if on a single post or page, or only one page present. */ function ygf_numeric_posts_nav() { if (is_singular()) { return; } global $wp_query; //* Stop execution if there's only 1 page if ($wp_query->max_num_pages <= 1) { return; } $paged = get_query_var('paged') ? absint(get_query_var('paged')) : 1; $max = intval($wp_query->max_num_pages); //* Add current page to the array if ($paged >= 1) { $links[] = $paged; } //* Add the pages around the current page to the array if ($paged >= 3) { $links[] = $paged - 1; $links[] = $paged - 2; } if ($paged + 2 <= $max) { $links[] = $paged + 2; $links[] = $paged + 1; } genesis_markup(array('html5' => '<div %s>', 'xhtml' => '<div class="navigation">', 'context' => 'archive-pagination')); echo '<ul class="pagination">'; //* Previous Post Link if (get_previous_posts_link()) { printf('<li class="pagination-previous">%s</li>' . "\n", get_previous_posts_link(apply_filters('genesis_prev_link_text', '«' . __('Previous Page', 'genesis')))); } //* Link to first page, plus ellipses if necessary if (!in_array(1, $links)) { $class = 1 == $paged ? ' class="active current"' : ''; printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link(1)), '1'); if (!in_array(2, $links)) { echo '<li class="pagination-omission">…</li>'; } } //* Link to current page, plus 2 pages in either direction if necessary sort($links); foreach ((array) $links as $link) { $class = $paged == $link ? ' class="active current"' : ''; printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link($link)), $link); } //* Link to last page, plus ellipses if necessary if (!in_array($max, $links)) { if (!in_array($max - 1, $links)) { echo '<li class="pagination-omission">…</li>' . "\n"; } $class = $paged == $max ? ' class="active current"' : ''; printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link($max)), $max); } //* Next Post Link if (get_next_posts_link()) { printf('<li class="pagination-next">%s</li>' . "\n", get_next_posts_link(apply_filters('genesis_next_link_text', __('Next Page', 'genesis') . '»'))); } echo '</ul></div>' . "\n"; }
function hsinsider_the_posts_navigation() { if (!is_single()) { echo '<nav class="navigation post-navigation" role="navigation"><div class="nav-previous alignleft">' . get_next_posts_link('<i class="LATArrowLeft01"></i>Older Articles') . '</div><div class="nav-next alignright">' . get_previous_posts_link('Newer Articles<i class="LATArrowRight01"></i>') . '</div></nav>'; } else { echo '<nav class="navigation post-navigation" role="navigation"><div class="nav-previous alignleft">' . get_previous_post_link('%link', '<i class="LATArrowLeft01"></i>%title') . '</div><div class="nav-next alignright">' . get_next_post_link('%link', '%title<i class="LATArrowRight01"></i>') . '</div></nav>'; } }
function geko_paging_nav() { if (is_singular()) { return; } global $wp_query; /** Stop execution if there's only 1 page */ if ($wp_query->max_num_pages <= 1) { return; } $paged = get_query_var('paged') ? absint(get_query_var('paged')) : 1; $max = intval($wp_query->max_num_pages); /** Add current page to the array */ if ($paged >= 1) { $links[] = $paged; } /** Add the pages around the current page to the array */ if ($paged >= 3) { $links[] = $paged - 1; $links[] = $paged - 2; } if ($paged + 2 <= $max) { $links[] = $paged + 2; $links[] = $paged + 1; } echo '<div class="pagination_wrapper text-center"><ul class="pagination">' . "\n"; /** Previous Post Link */ if (get_previous_posts_link()) { printf('<li>%s</li>' . "\n", get_previous_posts_link("<<")); } /** Link to first page, plus ellipses if necessary */ if (!in_array(1, $links)) { $class = 1 == $paged ? ' class="first active"' : ' class="first"'; printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link(1)), '1'); if (!in_array(2, $links)) { echo '<li><span class="btn disabled">...</span></li>' . "\n"; } } /** Link to current page, plus 2 pages in either direction if necessary */ sort($links); foreach ((array) $links as $link) { $class = $paged == $link ? ' class="last active"' : ' class="last"'; printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link($link)), $link); } /** Link to last page, plus ellipses if necessary */ if (!in_array($max, $links)) { if (!in_array($max - 1, $links)) { echo '<li><span class="btn disabled">...</span></li>' . "\n"; } $class = $paged == $max ? ' class="active"' : ''; printf('<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url(get_pagenum_link($max)), $max); } /** Next Post Link */ if (get_next_posts_link()) { printf('<li>%s</li>' . "\n", get_next_posts_link(">>")); } echo '</ul></div>' . "\n"; }
/** * fr_do_posts_query * Runs a custom posts query using WP_Query. * * @since 1.0.0 * @version 1.0.0 * @return Object **/ function fr_do_posts_query($posts_per_page = 10, $post_type = false, $taxonomy = false, $meta = array(), $orderby = false) { global $wp_query, $paged; $args['posts_per_page'] = $posts_per_page; $args['paged'] = $paged; if ($post_type) { $args['post_type'] = $post_type; } if ($taxonomy) { $args['tax_query'] = $taxonomy; } if ($orderby) { $args['orderby'] = $orderby; } if (isset($meta['key']) && isset($meta['value'])) { $args['meta_key'] = $meta['key']; $args['meta_value'] = $meta['value']; } if (is_category()) { $query = get_query_var('cat'); $query = get_category($query); $query_slug = $query->slug; $query_name = $query->name; // Args. $args['category_name'] = $query_slug; } elseif (is_archive()) { $query_year = get_query_var('year'); $query_month = get_query_var('monthnum'); // Args. $args['year'] = $query_year; $args['monthnum'] = $query_month; } elseif (is_tag()) { $query = get_query_var('tag'); $query = get_category($query); $query_slug = $query->slug; $query_name = $query->name; // Args. $args['tag'] = $query_slug; } else { $query_slug = null; $query_name = null; } // Do custom query. $query = new WP_Query($args); // Debugging. // p($query->posts); // p($query->found_posts); // p($query->max_num_pages); // p($query->post_count); // p(get_option('posts_per_page')); // Get URL for next page based on custom query. $next = explode('"', get_next_posts_link('', $query->max_num_pages)); $next_url = !empty($next[1]) ? $next[1] : false; // Get URL for previous page based on custom query. $prev = explode('"', get_previous_posts_link('', $query->max_num_pages)); $prev_url = !empty($prev[1]) ? $prev[1] : false; return array('query' => $query, 'paged' => $paged, 'maxed' => (int) $query->max_num_pages, 'pagination_links' => array('prev' => $prev_url, 'next' => $next_url)); }