php - 我想添加元框,但它没有显示
问题描述
我正在尝试显示一个元框,该框输入来自 Woocommerce 产品的产品代码并将其显示到页面上。出于这个原因,我正在尝试添加具有此功能的元框。但元框未显示在自定义帖子类型中。
这些是我的代码:
add_action('init', 'add_gng_offer');
function add_gng_offer() {
$labels = array(
'name' => 'GnG Offer',
'singular_name' => 'GnG Offer',
'add_new' => 'Add New Offer',
'add_new_item' => 'Add new Offer',
'edit_item' => 'Edit Offer',
'new_item' => 'Add New Offer',
'view_items' => 'View Offers',
'search_items' => 'Search Offers',
'not_found' => 'No Offers Found',
'not_found_trash' => 'No Offers Found In Trash',
);
$supports = array(
'title',
'editor',
'thumbnail',
'comments',
'revisions'
);
$args = array(
'labels' => $labels,
'supports' => $supports,
'public' => true,
'capablity_type' => 'post',
'rewrite' => array('slug' => 'GnG Offers'),
'has_archive' => true,
'menu_position' => 6,
'menu_icon' => 'dashicons-calendar-alt',
'register_meta_box' => '',
);
register_post_type('GnG Offers', $args);
}
//Creating meta Boxes for Custom Post Type
function product_id_meta_box () {
add_meta_box(
'product_id',
'Product Field',
'product_function_callback',
'GnG Offer',
'side',
'default'
);
}
add_action('add_meta_boxes', 'product_id_meta_box');
另一个问题是如何在我输入产品 id 的情况下实现这种功能,它会在特定页面中显示产品。
解决方案
推荐阅读
- javascript - 在javascript中使用函数获取实时值
- javascript - 尽管状态发生了变化,但自定义钩子不会触发组件重新渲染
- python - 使用请求时 Python 超级强制 HTTP/2
- python - 如何将 CSV 文件中的行存储在字典中?
- sql - 如何使用 STUFF 和 FOR XML PATH 分隔与其行相关的唯一值
- excel - 在 Excel 中使用 VBA 根据单元格值将数据从一张表中提取到新表中
- javascript - 连续调用 Reactjs 获取失败
- ansible - Ansible如何展平字典
- sql - 查询以识别 SAP B1 中的滞销库存
- html - 无法更改表格宽度