add_action('add_meta_boxes', 'add_testbox');
function add_testbox() {
add_meta_box( 'testmetabox', 'Test Meta Box', 'testmetabox_content', 'post', 'side', 'low');
}
function testmetabox_content() {
echo "hi";
}
You can drag and drop the box into the spot you want it to display.
Make sure you always wrap the add_meta_box()
function in another function, then hook that in like I showed. If you call add_meta_box()
outside the function, you’ll get a fatal error.
This example is for WordPress 3.0 and above. As the WordPress Codex shows, the ‘add_meta_boxes’ hook I used was added in WP 3.0. If you’re using an older version of WordPress, (which you shouldn’t be), use ‘admin_init’ instead of ‘add_meta_boxes’.
Related Posts:
- Get List of Registered Meta Boxes and Removing Them
- How to add tab which is visible only in admin side of product in woocommerce? [closed]
- Dashboard like meta boxes in my plugin – how to save their position and open/closed state?
- Save metabox with multiple checkbox array
- How to Use WordPress Color Picker API in Custom Post Type Metabox
- How to create Image gallery Metabox in wordpress [closed]
- Conflicting save_post functions when passing the post id and saving custom meta boxes for different post types
- How to add meta boxes to the ‘Add new post’ screen?
- Rearranging Dashboard meta boxes with use of plugin/functions.php
- Plugin admin page meta_box toggle and order state not saving
- Metabox Not Showing on Custom Post Type But On Pages and Post
- Best choice of options/settings framework for plugin/theme development
- Admin auto-refresh is interfering with Firebug — how to prevent it?
- Show add_meta_box by selecting a specific category
- update post meta for checkbox in the admin when inserted in the front-end
- Custom Taxonomy to dropdown box on adminside wordpress
- Create & Save multiple Meta-boxes
- Add a Save Button to Custom Meta Box [duplicate]
- Dashboard – get status and position of metaboxes and pass them to ajax method
- Getting List of all registered Dashboard Widgets
- what is the difference between these phares?
- How to get Metabox custom field to show checked if value is updated using post meta query?
- How do I update a field of a meta box?
- Input value from metabox is not found in $_POST after post save
- Including comments meta box on a plugin page
- How to add a widget to the post editing view?
- Automating the process of shortcode generation in a plugin – how is it done?
- Meta box on options page save form problem
- Moving/dragging a metabox removes TinyMCE’s content
- Store custom meta box data as serialized array
- WP nonce field checkbox prints checked=’checked’ outside input field
- How to add custom post widgets as tags into wordpress
- Any way to update_post_meta with html content? It gets stripped and becomes empty
- Adjust query on single
- Can I attach a plugin via my add_filter callback contents?
- Metabox is not displaying
- Catch metabox values in Plugin
- want to show CMB2 metabox on woocommerce product data tab
- Why is $_POST empty when saving custom Meta Box?
- WP_List_Table Inside Metabox With Bulk Actions Not Working on Submit
- Save meta box data from selected dropdown list in bbpress reply form
- Metabox types list
- WordPress Filesystem create CSS-File – get Shortcode ID for Name
- How to save multiple values in custom post type from front end to back end
- add_meta_box does not display meta box in Admin
- Add WordPress Meta Box saved form input to WordPress RSS feed [duplicate]
- set a custom post type to a taxonomy term programmatically in metabox
- Dynamically getting tags in post edit screen
- How to show metabox just in post.php in admin?
- Plugin dev: How to multiply instances of a plugin in the same metabox?
- save_post not called in plugin / custom field still saving overwriting metaboxes
- Get fields of a widget
- Display Data’s metabox in page
- Show Metabox Images in slideshow instead of static
- How to set/change another post author by custom fields or something else?
- Saving metabox updates causing fatal error
- Best practices for using the transients API
- Elementor Fatal error: Class ‘Elementor\Widget_Base’ not found
- How Can I Add a Filter to Class Instance Only?
- Headers already sent error with CSV export plugin
- How to add HTML / Form to an Admin Bar Menu
- Unable to write test cases for a WordPress plugin using PHPUnit and WP-CLI
- How to update the language used by wordpress from a plugin
- Is there any background process that I can run from plugin without depending on page hits on a website without affecting page-load speed?
- Woocommerce how to update variable product price programitically?
- Using $wpdb object in a widget
- Unified Approach for Placing Option Pages
- Using wp_filesystem in Plugins to store customizer settings
- Can I use the different settings sections over different pages using the save options group?
- WordPress removing data attributes for scheduled post
- WYSIWYG editor in WP 3.2 plugin
- How do I write a shortcode that opens and closes?
- What is minimum time interval for which a cron be scheduled?
- Plugin writing: access file that was just uploaded
- Gutenberg blocks not getting styled on back end
- Using WPDB to output raw XML fails because of wp-blog-header.php
- How can I listen to events in Gutenberg block?
- It’s possible to passing a ref to FormTokenField from parent component using forwardRef?
- How to show filters on table when using WP_List_Table
- Add a default WP comment form to forum template
- Gutenberg: import dependency or assign from global variable?
- Silently register plugin pages
- Plugin: database creation
- Loading Modernizr (or other JavaScript libraries) for use in a plugin
- Plugin path comes wrongly
- How to replace settings in WordPress plugin from a theme
- How to validate inputs with filter in register_setting callback
- Problems with wierd characters and my plugin
- wp_new_user_notifications to notify user and admin about new user registration
- Is it possible to use the MySQL’s ORDER BY FIELD() clause as part of the pre_get_posts hook?
- Why User_login key doesn’t work with wp_update_user()
- How to limit number of category term display in home page grids?
- A question on init and activation hooks
- Getting data from dynamically allocated metaboxes within a custom post
- Add custom html classes to gutenberg wrapper
- Update database record in plugin
- Can I use a hook other than ‘init’ to handle form submissions?
- Do a summary based on sections in a post
- Plugin as custom page
- Deactivate plugin on registration