get_the_id

函式
get_the_id ( No parameters )
返回值
  • (int|false) The ID of the current item in the WordPress Loop. False if $post is not set.
定義位置
相關方法
get_the_guidget_the_dateget_the_timeget_cat_idget_the_title
引入
2.1.0
棄用
-

get_the_id: 這個函式檢索當前文章或頁面的ID。它不接受任何引數,以整數形式返回ID。

檢索WordPress迴圈中的當前專案的ID。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$post = get_post();
return ! empty( $post ) ? $post->ID : false;
}
function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid $post = get_post(); return ! empty( $post ) ? $post->ID : false; }
function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
	$post = get_post();
	return ! empty( $post ) ? $post->ID : false;
}

常見問題

FAQs
檢視更多 >