标签: 自定义文章类型

  • 给wordpress添加带区块编辑器的文章类型

    给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文件就可以实现,添加完了,在后台就可以看到新添加的自字义文章类型了 。