slugから、該当するカスタム投稿タイプの情報を取得する。
$post = get_page_by_path($slug, "OBJECT", $post_type);
投稿IDのみ取得するなら、次のとおり。
$post_id = get_page_by_path($slug, "OBJECT", $post_type)->ID;
$post_typeを省略すると、デフォルトで固定ページが選択される。
More than 5 years have passed since last update.
slugから、該当するカスタム投稿タイプの情報を取得する。
$post = get_page_by_path($slug, "OBJECT", $post_type);
投稿IDのみ取得するなら、次のとおり。
$post_id = get_page_by_path($slug, "OBJECT", $post_type)->ID;
$post_typeを省略すると、デフォルトで固定ページが選択される。
Register as a new user and use Qiita more conveniently