我为元框创建此功能并保存信息,但我无法保存信息并将其显示到字段中。
我的代码:
function reaction_buttons_meta2()
{
global $post;
$reaction_buttons_off2 = false;
if ( get_post_meta($post->ID, '_reaction_buttons_off2', true) ) {
$reaction_buttons_off = true;
}
update_post_meta($post->ID, 'reaction_buttons_off2', $_POST['reaction_buttons_off2']);
$meta=get_post_meta($post->ID, $field['reaction_buttons_off2'], true);
?>
<input type="text" id="reaction_buttons_off2" name="reaction_buttons_off2" value="<?php echo $meta[reaction_buttons_off2][0]; ?>">
<?php
}
function reaction_buttons_meta_box2()
{
add_meta_box('reaction_buttons2','Reaction Buttons','reaction_buttons_meta2','post','side');
add_meta_box('reaction_buttons2','Reaction Buttons','reaction_buttons_meta2','page','side');
}
add_action('admin_menu', 'reaction_buttons_meta_box2');
我需要放置一个简单的字段来存储一个选项,然后在模板帖子中显示它。