###前提:
プラグインCustom Post Type UIでカスタム投稿を作成し、Advanced Custom Fieldsで10項目のカスタムフィールドを作成、それをカスタム投稿ページ(single-temple.php)に出力済み。
Custom Post Type UI:
'post_type' => 'temple', 'taxonomy' => 'area', 'term' => 'central',
Advanced Custom Fields:
テキストエリア(フィールド名:time)や画像(フィールド名:image)など。
###実現したいこと:
●カスタム投稿ページ(single-temple.php)のカスタムフィールドを、何の関連もない新しい固定ページ(page-temple.php)に出力したい。
→全項目 あるいは 2~3項目を指定
###試したこと:
①.get_post_meta(投稿の特定のキーからカスタムフィールドの値を取得)の関数を記述し、該当カスタム投稿のID数字(191)を入れても出力しない。(フィールド名time)
<?php $time = get_post_meta(191, 'time', true); ?>
②.以下を記述すると、記事ID:191 のthe_content部分は出力したが、カスタムフィールドは出力しない。
<?php $post_id = 191; //数字は記事のIDを入力 $post = get_post($post_id, 'OBJECT' , edit); $post_include = apply_filters( 'the_content',$post->post_content); echo $post_include; ?>
●初めて利用させていただきます。
何の関連もない新しい固定ページに、カスタム投稿ページのカスタムフィールドを出力する記述を、ご教示いただきたく宜しくお願い致します。
回答1件
あなたの回答
tips
プレビュー