• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_adjacent_post_link函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: adjacent_post_link

/**
 * Display adjacent post link.
 *
 * Can be either next post link or previous.
 *
 * @since 2.5.0
 *
 * @param string       $format         Link anchor format.
 * @param string       $link           Link permalink format.
 * @param bool         $in_same_term   Optional. Whether link should be in a same taxonomy term.
 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded category IDs.
 * @param bool         $previous       Optional. Whether to display link to previous or next post. Default true.
 * @param string       $taxonomy       Optional. Taxonomy, if $in_same_term is true. Default 'category'.
 */
function adjacent_post_link($format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category')
{
    echo get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, $previous, $taxonomy);
}
开发者ID:rizkafitri,项目名称:WordPress-1,代码行数:18,代码来源:link-template.php


示例2: get_adjacent_post_link

 /**
  * @param array $args
  *
  * @return mixed|null
  */
 function get_adjacent_post_link($args = array())
 {
     if (!$this->has_post()) {
         $adjacent_post = null;
     } else {
         $args = wp_parse_args($args, array('format' => '<div class="nav-previous">%link</div>', 'link_format' => false, 'in_same_term' => false, 'excluded_terms' => '', 'taxonomy' => 'category', 'previous' => null));
         WPLib::push_post($this->_post);
         if (function_exists('get_adjacent_post_link')) {
             $adjacent_post = get_adjacent_post_link($args['format'], $args['link_format'], $args['in_same_term'], $args['excluded_terms'], $args['previous'], $args['taxonomy']);
         } else {
             /**
              * Add support to pre 3.7 WordPress
              *
              * @future Add error messages when taxonomy != category
              * @future and when 'link_format' is not false
              */
             $adjacent_post = get_adjacent_post_rel_link($args['format'], $args['in_same_term'], $args['excluded_terms'], $args['previous']);
         }
         WPLib::pop_post();
     }
     return $adjacent_post;
 }
开发者ID:wpscholar,项目名称:wplib,代码行数:27,代码来源:class-post-view-base.php


示例3: carelib_get_post_navigation

/**
 * Helper function to build a next and previous post navigation element on
 * single entries. This takes care of all the annoying formatting which usually
 * would need to be done within a template.
 *
 * I originally wanted to use the new get_the_post_navigation tag for this;
 * however, it's lacking a lot of the flexibility provided by using the old
 * template tags directly. Until WordPress core gets its act together, I guess
 * I'll just have to duplicate code for no good reason.
 *
 * @since  1.0.0
 * @access public
 * @param  array $args Empty array if no arguments.
 * @return string
 */
function carelib_get_post_navigation($args = array())
{
    if (is_attachment() || !is_singular()) {
        return;
    }
    $name = _carelib_get_post_type_name(get_queried_object());
    $defaults = apply_filters("{$GLOBALS['carelib_prefix']}_post_navigation_defaults", array('post_types' => array(), 'prev_format' => '<span class="nav-previous">%link</span>', 'next_format' => '<span class="nav-next">%link</span>', 'prev_text' => __('Previous', 'carelib') . esc_html($name), 'next_text' => __('Next', 'carelib') . esc_html($name), 'in_same_term' => false, 'excluded_terms' => '', 'taxonomy' => 'category'));
    $args = wp_parse_args($args, $defaults);
    $types = (array) $args['post_types'];
    // Bail if we're not on a single entry. All post types except pages are allowed by default.
    if (!is_singular($types) || !in_array('page', $types, true) && is_page()) {
        return false;
    }
    $required = isset($args['prev_format'], $args['prev_text'], $args['next_format'], $args['next_text'], $args['in_same_term'], $args['excluded_terms'], $args['taxonomy']);
    // Bail if required args have been removed via a filter.
    if (!$required) {
        return false;
    }
    $links = '';
    // Previous post link. Can be filtered via WP Core's previous_post_link filter.
    $links .= get_adjacent_post_link($args['prev_format'], $args['prev_text'], $args['in_same_term'], $args['excluded_terms'], true, $args['taxonomy']);
    // Next post link. Can be filtered via WP Core's next_post_link filter.
    $links .= get_adjacent_post_link($args['next_format'], $args['next_text'], $args['in_same_term'], $args['excluded_terms'], false, $args['taxonomy']);
    // Bail if we don't have any posts to link to.
    if (empty($links)) {
        return false;
    }
    return sprintf('<nav %s>%s</nav><!-- .nav-single -->', carelib_get_attr('nav', 'single'), $links);
}
开发者ID:wpsitecare,项目名称:carelib,代码行数:44,代码来源:template-entry.php


示例4: flagship_get_post_navigation

/**
 * Helper function to build a next and previous post navigation element on
 * single entries. This takes care of all the annoying formatting which usually
 * would need to be done within a template.
 *
 * I originally wanted to use the new get_the_post_navigation tag for this;
 * however, it's lacking a lot of the flexibility provided by using the old
 * template tags directly. Until WordPress core gets its act together, I guess
 * I'll just have to duplicate code for no good reason.
 *
 * @since  1.3.0
 * @access public
 * @param  $args array
 * @return string
 */
function flagship_get_post_navigation($args = array())
{
    $obj = get_post_type_object(get_post_type());
    $name = isset($obj->labels->singular_name) ? '&nbsp;' . $obj->labels->singular_name : '';
    $defaults = apply_filters('flagship_get_post_navigation_defaults', array('post_types' => array(), 'prev_format' => '<span class="nav-previous">%link</span>', 'next_format' => '<span class="nav-next">%link</span>', 'prev_text' => __('Previous', 'flagship-library') . esc_attr($name), 'next_text' => __('Next', 'flagship-library') . esc_attr($name), 'in_same_term' => false, 'excluded_terms' => '', 'taxonomy' => 'category'));
    $args = wp_parse_args($args, $defaults);
    // Bail if we're not on a single entry. All post types are allowed by default.
    if (!is_singular($args['post_types'])) {
        return;
    }
    $links = '';
    // Previous post link. Can be filtered via WP Core's previous_post_link filter.
    $links .= get_adjacent_post_link($args['prev_format'], $args['prev_text'], $args['in_same_term'], $args['excluded_terms'], true, $args['taxonomy']);
    // Next post link. Can be filtered via WP Core's next_post_link filter.
    $links .= get_adjacent_post_link($args['next_format'], $args['next_text'], $args['in_same_term'], $args['excluded_terms'], false, $args['taxonomy']);
    // Bail if we don't have any posts to link to.
    if (empty($links)) {
        return;
    }
    $output = '';
    $output .= '<nav ' . hybrid_get_attr('nav', 'single') . '>';
    $output .= $links;
    $output .= '</nav><!-- .nav-single -->';
    return $output;
}
开发者ID:flagshipwp,项目名称:flagship-library,代码行数:40,代码来源:template-general.php


示例5: adjacent_post_link

/**
 * Display adjacent post link.
 *
 * Can be either next post link or previous.
 *
 * @since 2.5.0
 * @uses get_adjacent_post_link()
 *
 * @param string $format Link anchor format.
 * @param string $link Link permalink format.
 * @param bool $in_same_cat Optional. Whether link should be in a same category.
 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
 * @param bool $previous Optional, default is true. Whether to display link to previous or next post.
 * @return string
 */
function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true)
{
    echo get_adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, $previous);
}
开发者ID:palimadra,项目名称:bubblegraphics-wpsite,代码行数:19,代码来源:link-template.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_adjacent_post_rel_link函数代码示例发布时间:2022-05-15
下一篇:
PHP get_adjacent_post函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap