給wordpress添加帶區塊編輯器的自定義文章類型
add_action( 'init', function() {
$args = array(
'public' => true,
'label' => 'News',
'show_in_rest' => true,
'template_lock' => 'all',
'template' => array(
array( 'core/paragraph', array(
'placeholder' => 'wodepress',
) ),
),
'supports' => array(
'title',
'editor',
'excerpt',
'custom-fields',
'thumbnail',
'page-attributes'
),
);
register_post_type( 'news', $args );
}
);
把代碼添加到functions.php文件就可以實現,添加完了,在后臺就可以看到新添加的自字義文章類型了 。