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。

function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
	$post = get_post();
	return ! empty( $post ) ? $post->ID : false;
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 18:32:58

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: