get_post_format_link

函式
get_post_format_link ( $format )
引數
  • (string) $format The post format slug.
    Required:
返回值
  • (string|WP_Error|false) The post format term link.
定義位置
相關方法
_post_format_linkget_post_format_stringget_post_formatget_post_format_stringsget_post_permalink
引入
3.1.0
棄用
-

get_post_format_link函式返回特定文章格式的URL。它有兩個引數:第一個引數是文章格式的名稱,第二個引數是文章的ID。如果不支援post格式,則此函式返回false。

返回一個指向文章格式索引的連結。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_post_format_link( $format ) {
$term = get_term_by( 'slug', 'post-format-' . $format, 'post_format' );
if ( ! $term || is_wp_error( $term ) ) {
return false;
}
return get_term_link( $term );
}
function get_post_format_link( $format ) { $term = get_term_by( 'slug', 'post-format-' . $format, 'post_format' ); if ( ! $term || is_wp_error( $term ) ) { return false; } return get_term_link( $term ); }
function get_post_format_link( $format ) {
	$term = get_term_by( 'slug', 'post-format-' . $format, 'post_format' );
	if ( ! $term || is_wp_error( $term ) ) {
		return false;
	}
	return get_term_link( $term );
}

常見問題

FAQs
檢視更多 >