本文整理汇总了PHP中get_adjacent_post函数的典型用法代码示例。如果您正苦于以下问题:PHP get_adjacent_post函数的具体用法?PHP get_adjacent_post怎么用?PHP get_adjacent_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_adjacent_post函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: dswoddil_post_nav
/**
* Display navigation to next/previous post when applicable.
*
* @since DSW oddil 1.0
*/
function dswoddil_post_nav()
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php
_e('Post navigation', 'dswoddil');
?>
</h1>
<div class="nav-links">
<?php
if (is_attachment()) {
previous_post_link('%link', __('<span class="meta-nav">Published In</span>%title', 'dswoddil'));
} else {
previous_post_link('%link', __('<span class="meta-nav">Previous Post</span>%title', 'dswoddil'));
next_post_link('%link', __('<span class="meta-nav">Next Post</span>%title', 'dswoddil'));
}
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
开发者ID:kalich5,项目名称:dsw-oddil,代码行数:32,代码来源:template-tags.php
示例2: post_nav
/**
* Display navigation to next/previous post when applicable.
*/
function post_nav()
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous || is_singular('page')) {
return;
}
$_previous_post_link = get_previous_post_link('<div class="nav-previous">%link</div>', _x('<span class="meta-nav">←</span> %title', 'Previous post link', 'the-one'));
$_next_post_link = get_next_post_link('<div class="nav-next">%link</div>', _x('%title <span class="meta-nav">→</span>', 'Next post link', 'the-one'));
?>
<nav class="navigation post-navigation" role="navigation">
<h4 class="screen-reader-text"><?php
_e('Post navigation', 'the-one');
?>
</h4>
<div class="nav-links">
<?php
if (!empty($_previous_post_link) && !empty($_next_post_link)) {
echo $_previous_post_link . $_next_post_link;
} elseif (!empty($_previous_post_link)) {
echo $_previous_post_link;
} elseif (!empty($_next_post_link)) {
echo '<div class="nav-previous"></div>' . $_next_post_link;
}
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
开发者ID:thefrosty,项目名称:The-One-Theme,代码行数:34,代码来源:template-tags.php
示例3: twentythirteen_post_nav
/**
* Displays navigation to next/previous post when applicable.
*
* @since Twenty Thirteen 1.0
*
* @return void
*/
function twentythirteen_post_nav()
{
global $post;
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post($post->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php
_e('Post navigation', 'twentythirteen');
?>
</h1>
<div class="nav-links">
<?php
/*
if ( ! next_post_link('%link') ) {
echo "Test!";
}
*/
previous_post_link('%link', _x('<span class="meta-nav">←</span> %title', 'Previous post link', 'twentythirteen'), $in_same_cat = true);
?>
<?php
next_post_link('%link', _x('%title <span class="meta-nav">→</span>', 'Next post link', 'twentythirteen'), $in_same_cat = true);
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
开发者ID:verbazend,项目名称:AWFA,代码行数:40,代码来源:functions.php
示例4: panopta2014_post_nav
/**
* Display navigation to next/previous post when applicable.
*
* @since Twenty Fourteen 1.0
*
* @return void
*/
function panopta2014_post_nav()
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<div class="row">
<div class="col-xs-12 col-sm-11 col-sm-offset-1">
<nav class="navigation post-navigation" role="navigation">
<div class="nav-links row">
<?php
if (is_attachment()) {
previous_post_link('%link', __('<div class="col-xs-12"><span class="meta-nav">Published In</span>%title</div>', 'twentyfourteen'));
} else {
previous_post_link('<div class="col-xs-12 col-sm-6">%link</div>', __('<i class="fa fa-angle-left"></i> <span class="meta-nav">Previous: </span>%title', 'twentyfourteen'));
next_post_link('<div class="col-xs-12 col-sm-6">%link</div>', __('<span class="meta-nav">Next: </span>%title <i class="fa fa-angle-right"></i>', 'twentyfourteen'));
}
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
</div>
</div>
<?php
}
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:34,代码来源:functions.php
示例5: zerif_post_nav
/**
* Display navigation to next/previous post when applicable.
*/
function zerif_post_nav()
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php
_e('Post navigation', 'zerif-lite');
?>
</h1>
<div class="row nav-links">
<?php
previous_post_link('<div class="col-md-4 text-left nav-previous">%link</div>', _x('<span class="meta-nav">←</span> %title', 'Previous post link', 'zerif-lite'));
echo '<div class="col-md-4 text-center"><a href="http://localhost/blog">Home</a></div>';
next_post_link('<div class="col-md-4 text-right nav-next">%link</div>', _x('%title <span class="meta-nav">→</span>', 'Next post link', 'zerif-lite'));
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
开发者ID:azkanurunala,项目名称:ThetaGlobal,代码行数:35,代码来源:template-tags.php
示例6: twentyfifteen_post_nav
/**
* Display navigation to next/previous post when applicable.
*
* @since Twenty Fifteen 1.0
*/
function twentyfifteen_post_nav()
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous || is_attachment() && 'attachment' == $previous->post_type) {
return;
}
$prev_class = $next_class = '';
if ($previous && has_post_thumbnail($previous->ID)) {
$prev_class = " has-post-thumbnail";
}
if ($next && has_post_thumbnail($next->ID)) {
$next_class = " has-post-thumbnail";
}
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php
esc_html_e('Post navigation', 'twentyfifteen');
?>
</h1>
<div class="nav-links">
<?php
if (is_attachment()) {
previous_post_link('<div class="nav-previous' . $prev_class . '">%link</div>', _x('<span class="meta-nav">Published In</span><span class="post-title">%title</span>', 'Parent post link', 'twentyfifteen'));
} else {
previous_post_link('<div class="nav-previous' . $prev_class . '">%link</div>', _x('<span class="meta-nav">Previous</span><span class="post-title">%title</span>', 'Previous post link', 'twentyfifteen'));
next_post_link('<div class="nav-next' . $next_class . '">%link</div>', _x('<span class="meta-nav">Next</span><span class="post-title">%title</span>', 'Next post link', 'twentyfifteen'));
}
?>
</div><!-- .nav-links -->
</nav><!-- .post-navigation -->
<?php
}
开发者ID:justatechnology,项目名称:Security,代码行数:39,代码来源:template-tags.php
示例7: jose_post_nav
/**
* Display navigation to next/previous post when applicable.
*/
function jose_post_nav()
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<?php
previous_post_link('<div class="item_nav nav-previous">%link</div>', _x('<span class="meta-nav"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="60" height="60" viewBox="0 0 60 60">
<g id="icomoon-ignore">
<line stroke-width="1" x1="" y1="" x2="" y2="" stroke="#449FDB" opacity=""></line>
</g>
<path d="M43.197 52.254c0.804 0.813 0.804 2.124 0 2.937s-2.103 0.813-2.907 0l-23.49-23.721c-0.804-0.813-0.804-2.127 0-2.937l23.49-23.724c0.804-0.813 2.103-0.813 2.907 0s0.804 2.124 0 2.937l-21.42 22.254 21.42 22.254z" class="blob"></path>
</svg></span> ', 'Previous post link', 'jose'));
next_post_link('<div class="item_nav nav-next">%link</div>', _x(' <span class="meta-nav"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="60" height="60" viewBox="0 0 60 60">
<g id="icomoon-ignore">
<line stroke-width="1" x1="" y1="" x2="" y2="" stroke="#449FDB" opacity=""></line>
</g>
<path d="M16.799 52.254c-0.804 0.813-0.804 2.124 0 2.937s2.103 0.813 2.907 0l23.49-23.721c0.804-0.813 0.804-2.127 0-2.937l-23.49-23.724c-0.804-0.813-2.103-0.813-2.907 0s-0.804 2.124 0 2.937l21.42 22.254-21.42 22.254z" class="blob"></path>
</svg></span>', 'Next post link', 'jose'));
?>
<?php
}
开发者ID:jayontraps,项目名称:jose,代码行数:30,代码来源:template-tags.php
示例8: cover_post_nav
/**
* Display navigation to next/previous post when applicable.
*
* @return void
*/
function cover_post_nav()
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php
_e('Post navigation', 'cover');
?>
</h1>
<div class="nav-links cf">
<?php
if ($previous) {
previous_post_link('<div class="nav-previous">%link</div>', _x('<h2 class="subtitle">' . __('Previous post', 'cover') . '</h2><h1 class="title">%title</h1>', 'Previous post link', 'cover'));
}
if ($next) {
$next_img_array = wp_get_attachment_image_src(get_post_thumbnail_id($next->ID), 'single-post-thumbnail');
$next_img = $next_img_array[0];
$class = '';
$style = '';
if ('' != $next_img) {
$class = ' featured-image';
$style = ' style="background-image: url(\'' . $next_img . '\')"';
}
next_post_link('<div class="nav-next">%link</div>', _x('<div class="cover' . $class . '"><div class="cover-background"' . $style . '></div><div class="cover-header"><h2 class="cover-subtitle">' . __('Next post', 'cover') . '</h2><h1 class="cover-title">%title</h1></div></div>', 'Next post link', 'cover'));
}
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
开发者ID:9x,项目名称:cover,代码行数:40,代码来源:template-tags.php
示例9: ct_tracks_further_reading
function ct_tracks_further_reading()
{
global $post;
// gets the next & previous posts if they exist
$previous_blog_post = get_adjacent_post(false, '', true);
$next_blog_post = get_adjacent_post(false, '', false);
if (get_the_title($previous_blog_post)) {
$previous_title = get_the_title($previous_blog_post);
} else {
$previous_title = "The Previous Post";
}
if (get_the_title($next_blog_post)) {
$next_title = get_the_title($next_blog_post);
} else {
$next_title = "The Next Post";
}
echo "<nav class='further-reading'>";
if ($previous_blog_post) {
echo "<p class='prev'>\n \t\t<span>Previous Post</span>\n \t\t<a href='" . get_permalink($previous_blog_post) . "'>" . $previous_title . "</a>\n\t </p>";
} else {
echo "<p class='prev'>\n <span>This is the oldest post</span>\n \t\t<a href='" . esc_url(home_url()) . "'>Return to Blog</a>\n \t</p>";
}
if ($next_blog_post) {
echo "<p class='next'>\n \t\t<span>Next Post</span>\n \t\t<a href='" . get_permalink($next_blog_post) . "'>" . $next_title . "</a>\n\t </p>";
} else {
echo "<p class='next'>\n <span>This is the newest post</span>\n \t\t<a href='" . esc_url(home_url()) . "'>Return to Blog</a>\n \t </p>";
}
echo "</nav>";
}
开发者ID:LdyNailih,项目名称:RespaldoServidor,代码行数:29,代码来源:deprecated.php
示例10: digistarter_post_nav
/**
* Display navigation to next/previous post when applicable.
*
* @return void
*/
function digistarter_post_nav()
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h3 class="screen-reader-text">
<?php
__('Post navigation', TRANSLATED_TEXT_DOMAIN);
?>
</h3>
<div class="nav-links">
<?php
previous_post_link('%link', wp_kses(_x('<span class="meta-nav prev">←</span> %title', 'Previous post link', TRANSLATED_TEXT_DOMAIN), array('span' => array('class' => array()))));
?>
<?php
next_post_link('%link', wp_kses(_x('%title <span class="meta-nav next">→</span>', 'Next post link', TRANSLATED_TEXT_DOMAIN), array('span' => array('class' => array()))));
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
开发者ID:ahmadawais,项目名称:Moxie-Lean,代码行数:34,代码来源:template-tags.php
示例11: the_post_navigation
/**
* Display navigation to next/previous post when applicable.
*
* @todo Remove this function when WordPress 4.3 is released.
*/
function the_post_navigation()
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<nav class="navigation post-navigation col-xs-12" role="navigation">
<h2 class="screen-reader-text"><?php
_e('Post navigation', 'flat-sassy-boots');
?>
</h2>
<div class="nav-links">
<?php
//previous_post_link( '<div class="nav-previous"><div class="nav-indicator">' . _x( 'Previous Post:', 'Previous post', 'flat-sassy-boots' ) . '</div><h1>%link</h1><i class="fa fa-arrow-left"></i></div>', '%title' );
//next_post_link( '<div class="nav-next"><div class="nav-indicator">' . _x( 'Next Post:', 'Next post', 'flat-sassy-boots' ) . '</div><h1>%link</h1><i class="fa fa-arrow-right"></i></div>', '%title' );
previous_post_link('<div class="nav-previous"><strong>%link</strong></div>', '%title');
next_post_link('<div class="nav-next"><strong>%link</strong></div>', '%title');
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
开发者ID:love4code,项目名称:flat-sassy-boots,代码行数:30,代码来源:template-tags.php
示例12: the_post_navigation
/**
* Display navigation to next/previous post when applicable.
*
* @todo Remove this function when WordPress 4.3 is released.
*/
function the_post_navigation()
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h2 class="screen-reader-text"><?php
_e('Post navigation', 'ncssm_sg');
?>
</h2>
<div class="nav-links">
<?php
previous_post_link('<div class="nav-previous">%link</div>', '%title');
next_post_link('<div class="nav-next">%link</div>', '%title');
?>
</div>
<!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
开发者ID:ajspencer,项目名称:NCSSM-SG-WordPress,代码行数:30,代码来源:template-tags.php
示例13: my_simone_post_nav
/**
* Display navigation to next/previous post when applicable.
*
* @return void
*/
function my_simone_post_nav()
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<div class="post-nav-box clear">
<h1 class="screen-reader-text"><?php
_e('Post navigation', 'my-simone');
?>
</h1>
<div class="nav-links">
<?php
previous_post_link('<div class="nav-previous"><div class="nav-indicator">' . _x('Previous Post:', 'Previous post', 'my-simone') . '</div><h1>%link</h1></div>', '%title');
next_post_link('<div class="nav-next"><div class="nav-indicator">' . _x('Next Post:', 'Next post', 'my-simone') . '</div><h1>%link</h1></div>', '%title');
?>
</div><!-- .nav-links -->
</div><!-- .post-nav-box -->
</nav><!-- .navigation -->
<?php
}
开发者ID:sintija,项目名称:wordpress_backup,代码行数:32,代码来源:template-tags.php
示例14: activetheme_post_nav
/**
* Displays navigation to next/previous post when applicable.
*
* @since Twenty Thirteen 1.0
*
* @return void
*/
function activetheme_post_nav()
{
global $post;
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post($post->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<?php
/* <h1 class="screen-reader-text"><?php _e( 'Post navigation', 'activetheme' ); ?></h1> */
?>
<div class="nav-links clearfix">
<?php
if (is_singular('article')) {
previous_post_link('%link', _x('<span class="meta-nav meta-nav-prev">←</span> Previous Article', 'Previous article link', 'activetheme'));
next_post_link('%link', _x('Next Article <span class="meta-nav meta-nav-next">→</span>', 'Next article link', 'activetheme'));
} else {
previous_post_link('%link', _x('<span class="meta-nav meta-nav-prev">←</span> Previous Post', 'Previous post link', 'activetheme'));
next_post_link('%link', _x('Next Post <span class="meta-nav meta-nav-next">→</span>', 'Next post link', 'activetheme'));
}
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
开发者ID:TaylorFoster90,项目名称:Breton-Bay,代码行数:37,代码来源:pager.php
示例15: uncode_post_navigation
/**
* Display navigation to next/previous post when applicable.
*/
function uncode_post_navigation($index_btn = '')
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
$output = '<nav class="post-navigation" role="navigation">
<ul class="navigation">';
$prev = get_previous_post_link('<li class="page-prev"><span class="btn-container">%link</span></li>', '<i class="fa fa-angle-left"></i><span>' . esc_html__('Prev', 'uncode') . '</span>');
if ($prev !== '') {
$output .= $prev;
} else {
$output .= '<li class="page-prev"><span class="btn-container"><span class="btn btn-link btn-icon-left btn-disable-hover"><i class="fa fa-angle-left"></i>' . esc_html__('Prev', 'uncode') . '</span></span></li>';
}
if ($index_btn !== '') {
$output .= '<li class="nav-back"><span class="btn-container">' . $index_btn . '</span></li>';
}
$next = get_next_post_link('<li class="page-next"><span class="btn-container">%link</span></li>', '<span>' . esc_html__('Next', 'uncode') . '</span><i class="fa fa-angle-right"></i>');
if ($next !== '') {
$output .= $next;
} else {
$output .= '<li class="page-next"><span class="btn-container"><span class="btn btn-link btn-icon-right btn-disable-hover">' . esc_html__('Next', 'uncode') . '<i class="fa fa-angle-right"></i></span></span></li>';
}
$output .= '</ul><!-- .navigation -->
</nav><!-- .post-navigation -->';
return $output;
}
开发者ID:b0123498765,项目名称:fithealthyandwealthy,代码行数:32,代码来源:template-tags.php
示例16: flat_post_nav
function flat_post_nav()
{
global $post;
$previous = is_attachment() ? get_post($post->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php
_e('Post navigation', 'flat');
?>
</h1>
<div class="nav-links">
<?php
previous_post_link('%link', _x('<span class="meta-nav">←</span> %title', 'Previous post link', 'flat'));
?>
<?php
next_post_link('%link', _x('%title <span class="meta-nav">→</span>', 'Next post link', 'flat'));
?>
</div>
</nav>
<?php
}
开发者ID:pivaker,项目名称:driverschool,代码行数:27,代码来源:template-tags.php
示例17: oceanic_post_nav
/**
* Display navigation to next/previous post when applicable.
*/
function oceanic_post_nav()
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php
_e('Post navigation', 'oceanic');
?>
</h1>
<div class="nav-links">
<?php
$slider_cats = get_theme_mod('oceanic-slider-cats', false);
$slider_cat_ids = array();
if ($slider_cats) {
$slider_cats = explode(',', esc_html($slider_cats));
for ($i = 0; $i < count($slider_cats); ++$i) {
$cat_id = get_cat_ID($slider_cats[$i]);
if ($cat_id > 0) {
$slider_cat_ids[$i] = $cat_id;
}
}
}
previous_post_link('<div class="nav-previous">%link</div>', _x('<span class="meta-nav">←</span> %title', 'Previous post link', 'oceanic'), false, $slider_cat_ids);
next_post_link('<div class="nav-next">%link</div>', _x('%title <span class="meta-nav">→</span>', 'Next post link', 'oceanic'), false, $slider_cat_ids);
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
开发者ID:neetudave,项目名称:heartfulness-uk,代码行数:37,代码来源:template-tags.php
示例18: tutannet_post_navigation
/**
* Display navigation to next/previous post when applicable.
*
* @todo Remove this function when WordPress 4.3 is released.
*/
function tutannet_post_navigation()
{
$trans_next = of_get_option('trans_next_article');
if (empty($trans_next)) {
$trans_next = __('Next article', 'tutannet');
}
$trans_prev = of_get_option('trans_previous_article');
if (empty($trans_prev)) {
$trans_prev = __('Previous article', 'tutannet');
}
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<nav class="navigation post-navigation clearfix" role="navigation">
<h2 class="screen-reader-text"><?php
_e('Post navigation', 'tutannet');
?>
</h2>
<div class="nav-links">
<?php
previous_post_link('<div class="nav-previous"><div class="link-caption"><i class="fa fa-angle-left"></i>' . esc_attr($trans_prev) . '</div>%link</div>', '%title');
next_post_link('<div class="nav-next"><div class="link-caption">' . esc_attr($trans_next) . '<i class="fa fa-angle-right"></i></div>%link</div>', '%title');
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
开发者ID:vinhvv75,项目名称:tutannet,代码行数:36,代码来源:template-tags.php
示例19: blue_planet_post_nav
/**
* Display navigation to next/previous post when applicable.
*
* @deprecated 2.1 Use the_post_navigation()
*/
function blue_planet_post_nav()
{
// Don't print empty markup if there's nowhere to navigate.
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php
esc_html_e('Post navigation', 'blue-planet');
?>
</h1>
<div class="nav-links">
<?php
previous_post_link('%link', '<span class="meta-nav">←</span> %title');
?>
<?php
next_post_link('%link', '%title <span class="meta-nav">→</span>');
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
开发者ID:jbbythebch,项目名称:client1wp_test,代码行数:30,代码来源:template-tags.php
示例20: foundation_post_nav_background
/**
* Add featured image as background image to post navigation elements.
*
* @since Foundation Theme 0.5.0
*
* @see wp_add_inline_style()
*/
function foundation_post_nav_background()
{
if (!is_single()) {
return;
}
$previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
$css = '';
if (is_attachment() && 'attachment' == $previous->post_type) {
return;
}
if ($previous && has_post_thumbnail($previous->ID)) {
$prevthumb = wp_get_attachment_image_src(get_post_thumbnail_id($previous->ID), 'post-thumbnail');
$css .= '
.post-navigation .nav-previous { background-image: url(' . esc_url($prevthumb[0]) . '); }
.post-navigation .nav-previous .post-title, .post-navigation .nav-previous a:hover .post-title, .post-navigation .nav-previous .meta-nav { color: #fff; }
.post-navigation .nav-previous a:before { background-color: rgba(0, 0, 0, 0.4); }
';
}
if ($next && has_post_thumbnail($next->ID)) {
$nextthumb = wp_get_attachment_image_src(get_post_thumbnail_id($next->ID), 'post-thumbnail');
$css .= '
.post-navigation .nav-next { background-image: url(' . esc_url($nextthumb[0]) . '); border-top: 0; }
.post-navigation .nav-next .post-title, .post-navigation .nav-next a:hover .post-title, .post-navigation .nav-next .meta-nav { color: #fff; }
.post-navigation .nav-next a:before { background-color: rgba(0, 0, 0, 0.4); }
';
}
wp_add_inline_style('main-stylesheet', $css);
}
开发者ID:adam1920,项目名称:FoundationTheme,代码行数:36,代码来源:posts_navigation.php
注:本文中的get_adjacent_post函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论