get_parent_post_rel_link

函式
get_parent_post_rel_link ( $title = '%title' )
引數
  • (string) $title Optional. Link title format. Default '%title'.
    Required:
    Default: '%title'
返回值
  • (string)
定義位置
相關方法
parent_post_rel_linkget_adjacent_post_rel_linkstart_post_rel_linkprev_post_rel_linkget_boundary_post_rel_link
引入
2.8.0
棄用
3.3.0

get_parent_post_rel_link函式是一個WordPress函式,用於檢索一個文章的父文章的URL: 這個函式不接受任何引數: 該函式返回父帖的URL。

獲取父級文章關係連結。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_parent_post_rel_link( $title = '%title' ) {
_deprecated_function( __FUNCTION__, '3.3.0' );
if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) )
$post = get_post($GLOBALS['post']->post_parent);
if ( empty($post) )
return;
$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 = "<link rel='up' title='";
$link .= esc_attr( $title );
$link .= "' href='" . get_permalink($post) . "' />n";
return apply_filters( "parent_post_rel_link", $link );
}
function get_parent_post_rel_link( $title = '%title' ) { _deprecated_function( __FUNCTION__, '3.3.0' ); if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) $post = get_post($GLOBALS['post']->post_parent); if ( empty($post) ) return; $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 = "<link rel='up' title='"; $link .= esc_attr( $title ); $link .= "' href='" . get_permalink($post) . "' />n"; return apply_filters( "parent_post_rel_link", $link ); }
function get_parent_post_rel_link( $title = '%title' ) {
	_deprecated_function( __FUNCTION__, '3.3.0' );

	if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) )
		$post = get_post($GLOBALS['post']->post_parent);

	if ( empty($post) )
		return;

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

	return apply_filters( "parent_post_rel_link", $link );
}

常見問題

FAQs
檢視更多 >