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


PHP get_previous_posts_page_link函数代码示例

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


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

示例1: link_rel_prev_next

function link_rel_prev_next()
{
    // <link rel="home" title="Home" href="http://url/of/home/page" />
    $prev_url = '';
    $next_url = '';
    if (!is_singular()) {
        $prev_url = get_previous_posts_page_link();
        $next_url = get_next_posts_page_link();
        if (!empty($prev_url)) {
            printf('<link rel="prev" href="%s" />' . "\n", $prev_url);
        }
        if (!empty($next_url)) {
            printf('<link rel="next" href="%s" />' . "\n", $next_url);
        }
    } else {
        global $post;
        // $up_post = get_post($post->post_parent);
        //
        // $prev_post = get_previous_post();
        // if ( !empty( $prev_post->ID))
        //   printf( '<link rel="prev" title="%s" href="%s" />' . "\n", $prev_post->post_title , get_permalink($prev_post->ID) );
        //
        // $next_post = get_next_post();
        // if ( !empty($next_post->ID))
        //   printf( '<link rel="next" title="%s" href="%s" />' . "\n", $prev_post->post_title , get_permalink($next_post->ID) );
        safe_link_rel('next', get_post($post->parent));
        safe_link_rel('prev', get_previous_post());
        safe_link_rel('next', get_next_post());
    }
}
开发者ID:josephholsten,项目名称:Link-rel-prev-next,代码行数:30,代码来源:link_rel_prev_next.php

示例2: previous_posts

/**
 * Display or return the previous posts page link.
 *
 * @since 0.71
 *
 * @param bool $echo Optional. Echo or return;
 * @return string|void The previous posts page link if `$echo = false`.
 */
function previous_posts($echo = true)
{
    $output = esc_url(get_previous_posts_page_link());
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:rizkafitri,项目名称:WordPress-1,代码行数:17,代码来源:link-template.php

示例3: previous_posts

function previous_posts()
{
    echo clean_url(get_previous_posts_page_link());
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:4,代码来源:link-template.php

示例4: wp_head


//.........这里部分代码省略.........
     if (!empty($publisher)) {
         $meta_string = '<link rel="publisher" href="' . esc_url($publisher) . '" />' . "\n" . $meta_string;
     }
     if (is_singular() && !empty($googleplus)) {
         $author = $googleplus;
     } else {
         if (!empty($aioseop_options['aiosp_google_publisher'])) {
             $author = $aioseop_options['aiosp_google_publisher'];
         }
     }
     $author = apply_filters('aioseop_google_author', $author);
     if (!empty($author)) {
         $meta_string = '<link rel="author" href="' . esc_url($author) . '" />' . "\n" . $meta_string;
     }
     if ($is_front_page && !empty($front_meta)) {
         if (isset($meta_string)) {
             $meta_string .= "\n";
         }
         $meta_string .= $front_meta;
     } else {
         if (is_home() && !empty($home_meta)) {
             if (isset($meta_string)) {
                 $meta_string .= "\n";
             }
             $meta_string .= $home_meta;
         }
     }
     $prev = $next = '';
     if (is_home() || is_archive() || is_paged()) {
         global $wp_query;
         $max_page = $wp_query->max_num_pages;
         $page = $this->get_page_number();
         if ($page > 1) {
             $prev = get_previous_posts_page_link();
         }
         if ($page < $max_page) {
             //					$next = get_next_posts_page_link( $max_page );
             $paged = $GLOBALS['paged'];
             if (!is_single()) {
                 if (!$paged) {
                     $paged = 1;
                 }
                 $nextpage = intval($paged) + 1;
                 if (!$max_page || $max_page >= $nextpage) {
                     $next = get_pagenum_link($nextpage);
                 }
             }
         }
     } else {
         if (is_page() || is_single()) {
             $numpages = 1;
             $multipage = 0;
             $page = get_query_var('page');
             if (!$page) {
                 $page = 1;
             }
             if (is_single() || is_page() || is_feed()) {
                 $more = 1;
             }
             $content = $post->post_content;
             if (false !== strpos($content, '<!--nextpage-->')) {
                 if ($page > 1) {
                     $more = 1;
                 }
                 $content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);
                 $content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);
开发者ID:mahassan,项目名称:shellneverknow,代码行数:67,代码来源:aioseop_class.php

示例5: get_prev_next_links

 /**
  * @param null $post
  *
  * @return array
  */
 function get_prev_next_links($post = null)
 {
     $prev = $next = '';
     $page = $this->get_page_number();
     if (is_home() || is_archive() || is_paged()) {
         global $wp_query;
         $max_page = $wp_query->max_num_pages;
         if ($page > 1) {
             $prev = get_previous_posts_page_link();
         }
         if ($page < $max_page) {
             $paged = $GLOBALS['paged'];
             if (!is_single()) {
                 if (!$paged) {
                     $paged = 1;
                 }
                 $nextpage = intval($paged) + 1;
                 if (!$max_page || $max_page >= $nextpage) {
                     $next = get_pagenum_link($nextpage);
                 }
             }
         }
     } else {
         if (is_page() || is_single()) {
             $numpages = 1;
             $multipage = 0;
             $page = get_query_var('page');
             if (!$page) {
                 $page = 1;
             }
             if (is_single() || is_page() || is_feed()) {
                 $more = 1;
             }
             $content = $post->post_content;
             if (false !== strpos($content, '<!--nextpage-->')) {
                 if ($page > 1) {
                     $more = 1;
                 }
                 $content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);
                 $content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);
                 $content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);
                 // Ignore nextpage at the beginning of the content.
                 if (0 === strpos($content, '<!--nextpage-->')) {
                     $content = substr($content, 15);
                 }
                 $pages = explode('<!--nextpage-->', $content);
                 $numpages = count($pages);
                 if ($numpages > 1) {
                     $multipage = 1;
                 }
             }
             if (!empty($page)) {
                 if ($page > 1) {
                     $prev = _wp_link_page($page - 1);
                 }
                 if ($page + 1 <= $numpages) {
                     $next = _wp_link_page($page + 1);
                 }
             }
             if (!empty($prev)) {
                 $prev = $this->substr($prev, 9, -2);
             }
             if (!empty($next)) {
                 $next = $this->substr($next, 9, -2);
             }
         }
     }
     return array('prev' => $prev, 'next' => $next);
 }
开发者ID:recetasdemama,项目名称:wordpress,代码行数:74,代码来源:aioseop_class.php

示例6: get_previous_posts_page_link

<nav id="nav-below" class="navigation" role="navigation">
    <div class="nav-previous"><a href="<?php 
echo get_previous_posts_page_link();
?>
">Previous Page</a></div>
<div class="nav-next"><a href="<?php 
echo get_next_posts_page_link();
?>
">Next Page</a></div>
</nav>
开发者ID:sistercylon,项目名称:loverboy-wp-local,代码行数:10,代码来源:nav-below-cat.php

示例7: previous_posts

/**
 * Display or return the previous posts pages link.
 *
 * @since 0.71
 *
 * @param boolean $echo Optional. Echo or return;
 */
function previous_posts( $echo = true ) {
	$output = clean_url( get_previous_posts_page_link() );

	if ( $echo )
		echo $output;
	else
		return $output;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:15,代码来源:link-template.php

示例8: genesis_paged_rel

/**
 * Output rel links in the head to indicate previous and next pages in paginated archives and posts.
 *
 * @link  http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html
 *
 * @since 2.2.0
 */
function genesis_paged_rel()
{
    global $wp_query;
    $prev = $next = '';
    $paged = intval(get_query_var('paged'));
    $page = intval(get_query_var('page'));
    if (!is_singular()) {
        $prev = $paged > 1 ? get_previous_posts_page_link() : $prev;
        $next = $paged < $wp_query->max_num_pages ? get_next_posts_page_link($wp_query->max_num_pages) : $next;
    } else {
        //* No need for this on previews
        if (is_preview()) {
            return '';
        }
        $numpages = substr_count($wp_query->post->post_content, '<!--nextpage-->') + 1;
        if ($numpages && !$page) {
            $page = 1;
        }
        if ($page > 1) {
            $prev = genesis_paged_post_url($page - 1);
        }
        if ($page < $numpages) {
            $next = genesis_paged_post_url($page + 1);
        }
    }
    if ($prev) {
        printf('<link rel="prev" href="%s" />' . "\n", esc_url($prev));
    }
    if ($next) {
        printf('<link rel="next" href="%s" />' . "\n", esc_url($next));
    }
}
开发者ID:robalford,项目名称:alfordhomesinc,代码行数:39,代码来源:header.php

示例9: get_next_posts_page_link

<div class="panel panel--subtle">
	<nav class="pagination nav nav--pagination">
		<?php 
// Navigation links.
if (get_next_posts_link()) {
    echo '<a rel="next" href="' . get_next_posts_page_link() . '" class="btn next ss-navigateright">Next</a>';
}
if (get_previous_posts_link()) {
    echo '<a rel="previous" href="' . get_previous_posts_page_link() . '" class="btn prev ss-navigateleft">Previous</a>';
}
// Number of pages.
echo 'Page ' . ($wp_query->query_vars['paged'] ?: 1) . ' of ' . $wp_query->max_num_pages;
?>
	</nav>
</div><!--/.panel -->
开发者ID:jtuds,项目名称:base-wordpress-github,代码行数:15,代码来源:layout-pagination.php

示例10: numeric_posts_nav

/**
 * Print numeric pagination
 */
function numeric_posts_nav($custom_query = null)
{
    if (is_singular() && $custom_query === null) {
        return;
    }
    global $wp_query;
    if ($custom_query) {
        $wp_query = $custom_query !== null ? $custom_query : $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="numbered-pagination"><ul class="unstyled inline">' . "\n";
    /**	Previous Post Link */
    if (get_previous_posts_link()) {
        printf('<li><a href="%s" class="prev">%s</a></li>' . "\n", get_previous_posts_page_link(), print_image('arrow_blue.svg'));
    }
    /**	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><a href="%s" class="next">%s</a></li>' . "\n", get_next_posts_page_link(), print_image('arrow_blue.svg'));
    }
    echo '</ul></div>' . "\n";
}
开发者ID:aiganebraska,项目名称:Scholarship,代码行数:64,代码来源:etc_extras.php

示例11: previous_posts_link

 function previous_posts_link($label = '&laquo; Previous Page')
 {
     global $paged;
     $link = '';
     if (!is_single() && $paged > 1) {
         $link .= '<a href="';
         $link .= clean_url(get_previous_posts_page_link());
         $link .= '">' . preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) . '</a>';
     }
     return $link;
 }
开发者ID:Alenjandro,项目名称:data-my-share,代码行数:11,代码来源:remix_advanced_editor.php

示例12: ks_previous_posts_link

function ks_previous_posts_link()
{
    if (is_single()) {
        return;
    }
    $defaults = array('anchor' => '<img localsrc="7" alt="&laquo; ">' . __('*.Prev', 'ktai_style'), 'accesskey' => '*', 'echo' => true);
    $r = _ks_parse_arg(func_get_args(), $defaults);
    if (isset($r['label'])) {
        $r['anchor'] = $r['label'];
    }
    $paged = intval(get_query_var('paged'));
    $output = '';
    if ($paged > 1) {
        $output = '<a href="' . KtaiStyle::strip_host(clean_url(_ks_quoted_remove_query_arg('kp', get_previous_posts_page_link()))) . '"' . ks_accesskey_html($r['accesskey']) . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/', '&amp;$1', $r['anchor']) . '</a>';
    }
    if ($r['echo']) {
        echo $output;
    }
    return $output;
}
开发者ID:masayukiando,项目名称:wordpress-event-search,代码行数:20,代码来源:template-tags.php


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