Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
「ブログ」というページ名があり、投稿のリストが含まれています。
設定 -> 閲覧 -> "投稿ページ" で "ブログ" を選択しました。
テンプレートからブログの ID を取得するにはどうすればよいですか。
投稿ページとして「ブログ」を選択する必要がある場合は、ページセクションで以前に作成したページである必要があります。
現在のページの ID を取得するには、ページ テンプレートで投稿のループに入る前に $post->ID を実行するだけです。まず、global $postしかしを行います。このような:
global $post
<?php global $post; $current_page_id = $post->ID; // Whatever else you're going to do ?>