_post_format_link

函式
_post_format_link ( $link, $term, $taxonomy )
Access
Private
引數
  • (string) $link
    Required:
  • (WP_Term) $term
    Required:
  • (string) $taxonomy
    Required:
返回值
  • (string)
定義位置
相關方法
get_post_format_linkget_post_format_stringpost_permalinkhas_post_formatget_post_format
引入
3.1.0
棄用
-

_post_format_link: 這個函式用於生成一個指向特定文章格式的存檔頁面的連結。它需要一個引數,即$format,它是文章格式的標題: 這個函式在WordPress主題中經常被用來顯示文章格式存檔頁的連結。

過濾文章的格式條款連結,刪除格式字首。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function _post_format_link( $link, $term, $taxonomy ) {
global $wp_rewrite;
if ( 'post_format' !== $taxonomy ) {
return $link;
}
if ( $wp_rewrite->get_extra_permastruct( $taxonomy ) ) {
return str_replace( "/{$term->slug}", '/' . str_replace( 'post-format-', '', $term->slug ), $link );
} else {
$link = remove_query_arg( 'post_format', $link );
return add_query_arg( 'post_format', str_replace( 'post-format-', '', $term->slug ), $link );
}
}
function _post_format_link( $link, $term, $taxonomy ) { global $wp_rewrite; if ( 'post_format' !== $taxonomy ) { return $link; } if ( $wp_rewrite->get_extra_permastruct( $taxonomy ) ) { return str_replace( "/{$term->slug}", '/' . str_replace( 'post-format-', '', $term->slug ), $link ); } else { $link = remove_query_arg( 'post_format', $link ); return add_query_arg( 'post_format', str_replace( 'post-format-', '', $term->slug ), $link ); } }
function _post_format_link( $link, $term, $taxonomy ) {
	global $wp_rewrite;
	if ( 'post_format' !== $taxonomy ) {
		return $link;
	}
	if ( $wp_rewrite->get_extra_permastruct( $taxonomy ) ) {
		return str_replace( "/{$term->slug}", '/' . str_replace( 'post-format-', '', $term->slug ), $link );
	} else {
		$link = remove_query_arg( 'post_format', $link );
		return add_query_arg( 'post_format', str_replace( 'post-format-', '', $term->slug ), $link );
	}
}

常見問題

FAQs
檢視更多 >