本文整理汇总了PHP中get_previous_posts_link函数的典型用法代码示例。如果您正苦于以下问题:PHP get_previous_posts_link函数的具体用法?PHP get_previous_posts_link怎么用?PHP get_previous_posts_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_previous_posts_link函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: woo_pagenav
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
}
示例2: cleanblog_posts_navigation
/**
* 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
}
示例3: page_navi
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 . "";
}
示例4: nice_pagenavi
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
}
}
示例5: orbit_content_nav
/**
* 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
}
示例6: silencio_paging_nav
/**
* 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
}
示例7: page_navigation
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
}
示例8: rel_next_prevlink_tags
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;
}
}
}
示例9: boardwalk_body_classes
/**
* 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;
}
示例10: showHome
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));
}
示例11: am_paging_nav
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
}
示例12: woo_pagenav
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
}
示例13: sunspot_content_nav
/**
* 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
}
示例14: sketch_paging_nav
/**
* 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
}
示例15: cinnamon_paging_nav_newer
/**
* 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
}