Custom Post Type UIプラグインで管理しているカスタム投稿タイプで、投稿タイプの説明文をブログに出力する方法の紹介です。
Custom Post Type UIプラグインのインストール
管理画面のプラグイン新規追加よりCustom Post Type UIを検索するか、以下のページよりプラグインファイルをダウンロードします。Custom Post Type UI

Custom Post Type UIを有効化したら、管理画面左メニューの「CPT UI」から「投稿タイプの追加と編集」へ進みます。

カスタム投稿タイプの説明文を取得して表示
投稿タイプの追加と編集ページで、ページ上部の「追加ラベル」にある「投稿タイプの説明」欄に、この投稿タイプの説明文を記述します。
ご利用のテーマファイル(例:投稿タイプスラッグがsampleの場合はarchive-sample.phpなど)を開いて、この説明文を出力したい箇所に以下のようなコードを追加します。
1 2 3 4 |
<?php $post_type = get_queried_object(); echo esc_attr($post_type->description); ?> |
コメント