Try this
add_action( 'add_meta_boxes', 'cd_meta_box_add' );
function cd_meta_box_add()
{
add_meta_box( 'my-meta-box-id', 'My First Meta Box', 'cd_meta_box_cb', 'post', 'normal', 'high' );
}
function cd_meta_box_cb()
{
echo 'What you put here, show\'s up in the meta box';
}
ps: you have some extra problematic lines, at the top of your code, that I removed, namely:
add_meta_box( 'my-meta-box-id', 'My First Meta Box', 'cd_meta_box_cb', 'post', 'normal', 'high' );
Update:
To add the metabox to your custom post type edit page, replace 'post'
with 'your-custom-post-type'
in this line:
add_meta_box( 'my-meta-box-id', 'My First Meta Box', 'cd_meta_box_cb', 'your-custom-post-type', 'normal', 'high' );
Related Posts:
- How to set default screen options?
- Does WordPress have a “Form API”?
- Metabox with checkbox is not updating
- Hiding a theme’s meta box
- Block metabox – No expanding, no moving around
- Access the environment of an admin page from another admin page
- Editing Screen: Make Update or Publish Button Follow The Page
- Add filter ‘wpautop’ to meta box textarea
- add_meta_box does not go ‘side’
- Custom meta box shown when template is chosen [duplicate]
- Modifying the main editor priority
- How to make a meta box field a requirement
- How do I stop HTML entities in a custom meta box from being un-htmlentitied?
- meta content on required pages
- How to remove the RichText Meta Box
- get_post_meta doesn’t work
- Add character count to custom metabox
- Update caption for metabox gallery images
- Dynamically Creating Meta Boxes
- Remove border on custom meta box
- Create a page Meta Box listing all blog users
- datetime_timestamp shows numbers only? need in date and time
- remove_meta_box for all post types doesn’t seem to work
- Custom Metabox with Ajax in Edit Post – Stuck
- make a excerpt on data from a meta box?
- How to put Periods and Spaces for Array Values (Meta Key)
- Meta box io oembed returns list not array
- How to verify meta box is registered in Unit Testing?
- Add a custom field to top attribute in WooCommerce
- wp_editor in metabox not working
- Select box saves but doesn’t update value in admin
- Add_meta_box not appearing, but does appear in screen options
- Change the post date from a meta box
- retrieve meta key when checkbox is used
- update_post_meta and get_post_meta not working
- Repeatable custom meta fields
- Get all meta boxes values
- How to display a custom post type’s media library inline on meta box
- Modules with meta box implementations
- Metabox saves on Update or Publish, but not on Saving Draft
- Checkbox on a meta box using CMB2 Plugin
- Decide Metabox Configurations for All Users
- metabox select – frontend display
- Set default post author to none on new post
- how to save and get selected item id list with add_meta_box
- Remove anchor tag from meta box link
- Show preview of post changes on page
- Add Metabox to settings / options page
- Undefined index error in custom post metabox
- WPAlchemy MediaAccess inserting media link in WP Editor instead of custom field in metabox [closed]
- Meta Box will not display
- cannot grab post meta from extended Walker_Category class properly
- Resetting admin post form on JS validation fail
- How do you List all Sidebars in a Metabox
- Create more Meta Boxes as needed
- Add a meta box to ALL Pages
- How can i use this meta box function in my template ? (WordPress)
- How to disable Author dropdown in Gutenberg’s Status and Visibility panel
- How to remove some metaboxes for CPTs?
- How to add metabox ONLY to specific WooCommerce product type [closed]
- Add metabox without the container
- wpalchemi metabox doesn’t show value from my post type
- HTML Table creator in metabox to put into post theme
- Display stored value in Meta Box
- How to use Gutenberg in CMB2?
- Display Content if custom meta box checkbox is checked
- How to check specific value in two metabox?
- How to show taxonomy terms from wordpress database?
- How can i get multi checkboxes value in metbox?
- Understanding WordPress’ post type support
- save radio button selection in post-meta on submit
- Custom meta box data in rss feed
- ShortCut on meta boxes
- Post edit screen: How to check if meta_box is registered?
- How using the Meta Box plugin, to filter posts by the value of a post type field?
- How to ‘clone’ select metabox options with a callback function? [closed]
- Saving multiple fields (dropdown and text) in custom metabox
- metabox dosn’t save with checkbox of post_type values order by taxonomy
- save meta data of custom post type: WP_Error has no effect, even if insufficient capabilities
- display all registered meta boxes
- where can i see the registered new field for posts using register_meta() ?
- update_post_meta doesn’t work
- Resposive admin classes?
- Make metabox always be on top (sticky)
- Ridiculous problem with CDATA [duplicate]
- Can’t save drop down select date in meta boxes
- WordPress check if value equals and echo “checked”
- Custom metabox for file upload return empty filename
- Video slideshow
- Meta Box Value not saving / populating?
- Customer portal (posts as checklist)
- How to set default screen options?
- Reload meta box content with AJAX
- why esc_url not working in smartmetabox
- Change Default Custom Fields Metabox Name on cctm plugin
- How to create metabox that can be queried in the database?
- Form submit from modal window to parent window
- Allow iframe in custom meta box
- Datepicker altField and altFormat to save a new meta key/value in a post?
- Is there a way to remove the Add boxes from the Screen Options menu metabox?