wp_is_post_revision

函式
wp_is_post_revision ( $post )
引數
  • (int|WP_Post) $post Post ID or post object.
    Required:
返回值
  • (int|false) ID of revision's parent on success, false if not a revision.
定義位置
相關方法
wp_list_post_revisionswp_save_post_revisionwp_get_post_revisionwp_get_post_revisions_wp_put_post_revision
引入
2.6.0
棄用
-

wp_is_post_revision: 這個函式用來檢查一個文章是否是WordPress中的修訂版。它接收一個文章ID或文章物件作為引數,如果該文章是修訂版,則返回真,否則返回假。

判斷指定的文章是否是修訂版。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_is_post_revision( $post ) {
$post = wp_get_post_revision( $post );
if ( ! $post ) {
return false;
}
return (int) $post->post_parent;
}
function wp_is_post_revision( $post ) { $post = wp_get_post_revision( $post ); if ( ! $post ) { return false; } return (int) $post->post_parent; }
function wp_is_post_revision( $post ) {
	$post = wp_get_post_revision( $post );

	if ( ! $post ) {
		return false;
	}

	return (int) $post->post_parent;
}

常見問題

FAQs
檢視更多 >