您好,我正在gallery中创建我的自定义复选框,我已经添加了该复选框,但保存不起作用,有人可以看一下并告诉我在哪里应该放置元键吗?
function wporg_add_custom_box()
{
$screens = [\'attachment\'];
foreach ($screens as $screen) {
add_meta_box(
\'wporg_box_id\', // Unique ID
\'Custom Meta Box Title\', // Box title
\'wporg_custom_box_html\', // Content callback, must be of type callable
$screen // Post type
);
}
}
add_action(\'add_meta_boxes\', \'wporg_add_custom_box\');
function wporg_custom_box_html($post)
{
$value = get_post_meta($post->ID, \'_wporg_meta_key\', true);
?>
<input type="checkbox" name="include_in_image_gallery" <?php selected($value, $post->ID); ?> >
<?php
}
function wporg_save_postdata($post_id)
{
if (array_key_exists(\'wporg_field\', $_POST)) {
update_post_meta(
$post_id,
\'_wporg_meta_key\',
$_POST[\'include_in_image_gallery\']
);
}
}
add_action(\'save_post\', \'wporg_save_postdata\');
我的元密钥名称是:include_in_image_gallery
我想在另一个子页面的wp\\u查询中使用该元。
有什么想法吗?谢谢并致以最良好的问候。