با تابع `register_post_type` درون اکشن `init` پست تایپ جدید با پشتیبانی از گوتنبرگ (`'show_in_rest' => true`) بسازید.
<?php
/**
* ثبت پست تایپ سفارشی نمونه کارها (Portfolio) با استانداردهای مدرن وردپرس
*/
function bisco_register_portfolio_cpt() {
$labels = array(
'name' => 'نمونه کارها',
'singular_name' => 'نمونه کار',
'menu_name' => 'نمونه کارها',
'add_new' => 'افزودن نمونه کار',
'add_new_item' => 'افزودن نمونه کار جدید',
'edit_item' => 'ویرایش نمونه کار',
'new_item' => 'نمونه کار جدید',
'view_item' => 'مشاهده نمونه کار',
'search_items' => 'جستجوی نمونه کارها',
'not_found' => 'هیچ نمونه کاری یافت نشد',
'not_found_in_trash' => 'در زبالهدان موردی یافت نشد',
);
$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true, // فعالسازی ویرایشگر گوتنبرگ و REST API
'query_var' => true,
'rewrite' => array( 'slug' => 'portfolio', 'with_front' => false ),
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 5,
'menu_icon' => 'dashicons-portfolio',
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'revisions' ),
);
register_post_type( 'portfolio', $args );
}
add_action( 'init', 'bisco_register_portfolio_cpt' );