get_boundary_post_rel_link

函式
get_boundary_post_rel_link ( $title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true )
引數
  • (string) $title Optional. Link title format. Default '%title'.
    Required:
    Default: '%title'
  • (bool) $in_same_cat Optional. Whether link should be in a same category. Default false.
    Required:
    Default: false
  • (string) $excluded_categories Optional. Excluded categories IDs. Default empty.
    Required:
    Default: (empty)
  • (bool) $start Optional. Whether to display link to first or last post. Default true.
    Required:
    Default: true
返回值
  • (string)
定義位置
相關方法
get_parent_post_rel_linkget_boundary_poststart_post_rel_linkget_post_reply_linkget_adjacent_post_rel_link
引入
2.8.0
棄用
3.3.0

get_boundary_post_rel_link: 這個函式根據文章日期檢索與當前文章有關的上一個或下一個文章的連結: 該函式接受與get_boundary_post相同的引數。

獲取邊界後的關係連結。

可以是開始或結束後的關係連結。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) {
_deprecated_function( __FUNCTION__, '3.3.0' );
$posts = get_boundary_post($in_same_cat, $excluded_categories, $start);
// If there is no post, stop.
if ( empty($posts) )
return;
// Even though we limited get_posts() to return only 1 item it still returns an array of objects.
$post = $posts[0];
if ( empty($post->post_title) )
$post->post_title = $start ? __('First Post') : __('Last Post');
$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 = $start ? "<link rel='start' title='" : "<link rel='end' title='";
$link .= esc_attr($title);
$link .= "' href='" . get_permalink($post) . "' />n";
$boundary = $start ? 'start' : 'end';
return apply_filters( "{$boundary}_post_rel_link", $link );
}
function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) { _deprecated_function( __FUNCTION__, '3.3.0' ); $posts = get_boundary_post($in_same_cat, $excluded_categories, $start); // If there is no post, stop. if ( empty($posts) ) return; // Even though we limited get_posts() to return only 1 item it still returns an array of objects. $post = $posts[0]; if ( empty($post->post_title) ) $post->post_title = $start ? __('First Post') : __('Last Post'); $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 = $start ? "<link rel='start' title='" : "<link rel='end' title='"; $link .= esc_attr($title); $link .= "' href='" . get_permalink($post) . "' />n"; $boundary = $start ? 'start' : 'end'; return apply_filters( "{$boundary}_post_rel_link", $link ); }
function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) {
	_deprecated_function( __FUNCTION__, '3.3.0' );

	$posts = get_boundary_post($in_same_cat, $excluded_categories, $start);
	// If there is no post, stop.
	if ( empty($posts) )
		return;

	// Even though we limited get_posts() to return only 1 item it still returns an array of objects.
	$post = $posts[0];

	if ( empty($post->post_title) )
		$post->post_title = $start ? __('First Post') : __('Last Post');

	$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 = $start ? "<link rel='start' title='" : "<link rel='end' title='";
	$link .= esc_attr($title);
	$link .= "' href='" . get_permalink($post) . "' />n";

	$boundary = $start ? 'start' : 'end';
	return apply_filters( "{$boundary}_post_rel_link", $link );
}

常見問題

FAQs
檢視更多 >