本文整理汇总了PHP中get_adjacent_post_rel_link函数的典型用法代码示例。如果您正苦于以下问题:PHP get_adjacent_post_rel_link函数的具体用法?PHP get_adjacent_post_rel_link怎么用?PHP get_adjacent_post_rel_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_adjacent_post_rel_link函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prev_post_rel_link
/**
* Display relational link for the previous post adjacent to the current post.
*
* @since 2.8.0
*
* @param string $title Optional. Link title 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 term IDs. Default true.
* @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
*/
function prev_post_rel_link($title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category')
{
echo get_adjacent_post_rel_link($title, $in_same_term, $excluded_terms, true, $taxonomy);
}
示例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;
}
示例3: prev_post_rel_link
/**
* Display relational link for the previous post adjacent to the current post.
*
* @since 2.8.0
*
* @param string $title Optional. Link title format.
* @param bool $in_same_cat Optional. Whether link should be in same category.
* @param string $excluded_categories Optional. Excluded categories IDs.
*/
function prev_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '')
{
echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', true);
}
示例4: get_adjacent_post_rel_link
/**
* This function mimics the WordPress function get_adjacent_post_rel_link()
* because we cannot use that function properly.
*
* In the WordPress function, get_adjacent_post_rel_link(), you are only allowed
* to use 'category' for your taxonomy but this function adds a new parameter that
* allows you to designate which CPT-onomy you would like to use.
*
* @since 1.0.2
* @uses $cpt_onomies_manager
* @param string $title Optional. Link title format.
* @param bool $in_same_cpt_onomy Optional. Whether link should be in a same CPT-onomy.
* @param array|string $excluded_term_ids Optional. Array or comma-separated list of excluded term IDs.
* @param bool $previous Optional, default is true. Whether to display link to previous or next post.
* @param string $cpt_onomy - name of the CPT-onomy for $in_same_cpt_onomy
* @return string
*/
function get_adjacent_post_rel_link($title = '%title', $in_same_cpt_onomy = false, $excluded_term_ids = '', $previous = true, $cpt_onomy = '')
{
global $cpt_onomies_manager;
if (empty($cpt_onomy) || !$cpt_onomies_manager->is_registered_cpt_onomy($cpt_onomy)) {
return get_adjacent_post_rel_link($title, $in_same_cpt_onomy, $excluded_term_ids, $previous);
}
if ($previous && is_attachment() && is_object($GLOBALS['post'])) {
$post =& get_post($GLOBALS['post']->post_parent);
} else {
$post = $this->get_adjacent_post($in_same_cpt_onomy, $excluded_term_ids, $previous, $cpt_onomy);
}
if (empty($post)) {
return;
}
if (empty($post->post_title)) {
$post->post_title = $previous ? __('Previous Post', CPT_ONOMIES_TEXTDOMAIN) : __('Next Post', CPT_ONOMIES_TEXTDOMAIN);
}
$date = mysql2date(get_option('date_format'), $post->post_date);
$title = str_replace('%title', $post->post_title, $title);
$title = str_replace('%date', $date, $title);
$title = apply_filters('the_title', $title, $post->ID);
$link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
$link .= esc_attr($title);
$link .= "' href='" . get_permalink($post) . "' />\n";
$adjacent = $previous ? 'previous' : 'next';
return apply_filters("{$adjacent}_post_rel_link", $link);
}