我想在自定義帖子類型中添加自定義字段。我想在自定義帖子類型中添加一個文本字段,但我不知道該怎麼做。這是我在我的主題中的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);
}