カスタム投稿タイプをプラグイン無しで実装する

U3
2017/10/12
2024/11/7

functions.phpに下記コードを追記。


/*カスタム投稿タイプ*/

add_action( 'init', 'my_post_type' );
function my_post_type() {
register_post_type(
'news',
array(
'rewrite' => array( 'with_front' => false ),
'label' => 'お知らせ',
'public' => true,
'exclude_from_search' => true,
'hierarchical' => true,
'has_archive' => true,
'menu_position' => 5,
'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'revisions', 'page-attributes')
)
);
}

 

「最近のカスタム投稿」をページ上に表示させるには

Custom Post Type Widgets

というプラグインを利用。

 


コメント

コメントはまだありません。