wordpress get current page postid code example
Example 1: get_the_id wordpress
function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
$post = get_post();
return ! empty( $post ) ? $post->ID : false;
}
Example 2: get the current page id in wordpress
$page_id = get_queried_object_id();