php 自定义帖子类型注册(W / Gutenberg支持)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 自定义帖子类型注册(W / Gutenberg支持)相关的知识,希望对你有一定的参考价值。
<?php
function location_init() {
$args = array(
'label' => 'Locations',
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => 'location'),
'query_var' => true,
'menu_icon' => 'dashicons-location',
'show_in_rest' => true, // This is Gutenberg required
'supports' => array(
'title',
'editor',
'excerpt',
'trackbacks',
'custom-fields',
'comments',
'revisions',
'thumbnail',
'author',
'page-attributes',)
);
register_post_type( 'location', $args );
}
add_action( 'init', 'location_init' );
以上是关于php 自定义帖子类型注册(W / Gutenberg支持)的主要内容,如果未能解决你的问题,请参考以下文章
php 自定义帖子类型注册
php 注册后过滤自定义帖子类型
php 注册多个自定义帖子类型CPT
php 注册多个自定义帖子类型CPT
php 注册自定义帖子类型和分类
php 注册多个自定义帖子类型