【发布时间】:2022-01-25 21:34:12
【问题描述】:
我对这个问题的目标是什么
我目前正在为 WordPress 网站构建自定义插件。当我的插件被激活时,它正在创建一个新的自定义帖子类型,它目前具有默认输入字段。
我希望这个新的自定义帖子类型拥有比默认的全新的输入字段不使用任何外部插件。
我发现了什么
我在网上搜索了很多关于“在 CPT 中创建海关字段?”,但我发现的只是使用 ACF 等插件的一些答案。我也去了 WordPress 的官方文档,但我只找到了如何创建一个新的 Custom Post Type。
我的代码
function __construct()
{
$this->plugin_name = plugin_basename(__FILE__);
add_action('init', array($this, 'custom_post_type'));
}
function custom_post_type(){
register_post_type('logos', ['public' => true, 'label' => 'Logo Upload']);
}
【问题讨论】:
-
谢谢!我去看看!
标签: php wordpress advanced-custom-fields custom-post-type custom-fields