我想在我的自定义帖子类型中添加一个自定义字段。我想在自定义帖子类型中添加一个文本字段,但我不知道该怎么做。这是我在主题的functions.php中实现的代码。
add_action( 'init', 'register_cpt_advert' );
function register_cpt_advert() {
$labels = array(
'name' => _x( 'Adverts', 'advert' ),
'singular_name' => _x( 'Advert', 'advert' ),
'add_new' => _x( 'Add New', 'advert' ),
'add_new_item' => _x( 'Add New Advert', 'advert' ),
'edit_item' => _x( 'Edit Advert', 'advert' ),
'new_item' => _x( 'New Advert', 'advert' ),
'view_item' => _x( 'View Advert', 'advert' ),
'search_items' => _x( 'Search Adverts', 'advert' ),
'not_found' => _x( 'No advert found', 'advert' ),
'not_found_in_trash' => _x( 'No adverts found in Trash', 'advert' ),
'parent_item_colon' => _x( 'Parent Advert:', 'advert' ),
'menu_name' => _x( 'Adverts', 'advert' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'Show image adverts on videos',
'supports' => array( 'title', 'thumbnail'),
//'taxonomies' => array( 'category', 'post_tag', 'page-category' ),
'public' => false,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => true,
'has_archive' => false,
'query_var' => false,
'can_export' => true,
'rewrite' => false,
'capability_type' => 'post'
);
register_post_type( 'advert', $args );
}