[WordPress] WP_Postに関する資料

Modified

『WordPress』のWP_Postクラスについて。

概要

WP_Postはデータベースから取得した投稿に関する情報を格納するクラス。

詳細は公式リファレンスのWP_Postを参照。

以降では利用頻度の高いもの、リファレンスのページに掲載がないもの、重要度の高いものに絞ってWP_Postを解説する。

プロパティ

$ID

投稿のID。

public int $ID

$post_author

投稿者のID。

public string $post_author

互換性のため、数値文字列として格納されている。

$post_date

投稿のローカル公開日時。

public string $post_date

『0000-00-00 00:00:00』という書式で格納されている。

$post_date_gmt

投稿のGMT公開日時。

public string $post_date_gmt

『0000-00-00 00:00:00』という書式で格納されている。

$post_content

投稿の本文。

public string $post_content

続きを読む(more)、ショートコード([])、ブロックエディタ用のHTMLコメントなどがそのまま格納されている。

$post_title

投稿のタイトル。

public string $post_title

$post_excerpt

投稿の抜粋。

public string $post_excerpt

$post_status

投稿の状態。

投稿が下書きである、公開されている等の情報。

public string $post_status

$comment_status

コメントの状態。

コメントが許可されているか等の情報。

public string $comment_status

$post_password

投稿に設定されているパスワード。

public string $post_password

平文で格納されている。

$post_name

投稿のスラッグ。

public string $post_name

$post_modified

投稿のローカル更新日時。

public string $post_modified

『0000-00-00 00:00:00』という書式で格納されている。

$post_modified_gmt

投稿のGMT更新日時。

public string $post_modified_gmt

『0000-00-00 00:00:00』という書式で格納されている。

$post_parent

親となる投稿のID。

public int $post_parent

親がない、自身が親の場合は0。

$post_type

投稿タイプ。

標準状態であれば投稿または固定ページを表す。

public string $post_type

値は次の通り。

投稿タイプ
標準の投稿 post
固定ページ page
カスタム投稿タイプ カスタム投稿タイプの識別