LoginSignup
0
0

More than 5 years have passed since last update.

カスタム投稿タイプのページslug名から投稿オブジェクトを取得する

Posted at

slugから、該当するカスタム投稿タイプの情報を取得する。

$post = get_page_by_path($slug, "OBJECT", $post_type);

投稿IDのみ取得するなら、次のとおり。

$post_id = get_page_by_path($slug, "OBJECT", $post_type)->ID;

$post_typeを省略すると、デフォルトで固定ページが選択される。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0