You shouldn’t.
To get the data for the correct post you should be using the $post variable passed to the callback function. This represents the post being edited. Therefore to get the metadata for the correct post you should call get_post_meta() inside the callback function.
Related Posts:
- add_meta_boxes action with refresh on save
- Save selected item from dropdown menu in a meta box as a metadata value for a custom post type
- Second select list values are not saved after clicking update
- Saving metabox repeatable fields
- OOP Plugin Development. Including external object
- How to select the contents in the text view textrea in wp_editor?
- Remove metabox from WordPress menu editor page?
- How to make my custom widget appear within WordPress widgets? Plugin development
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- Undefined method class::construct() when creating a plugin
- Cant register rest routs from class instance
- Using admin-post.php for admin form but it directs me to admin-post.php white screen
- How do I make this Metabox show current DB value?
- Call to “admin_notices” hook from a static method
- Save custom field on WP_List_Table
- Get value of submit button in custom post type
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- PHP calling function within a class
- Save data of select list after clicking save
- How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?
- Issues separating my Plugin pages into different files
- How do I change the Go To Categories link in the term_updated_messages
- Trouble with WordPress Settings API: Form Submits When Fields Called Directly, Fails When Using Callbacks
- How can I catch WordPress custom settings page slug has already changed?
- Should I use spl_autoload_register() in my plugin?
- How can I save a multiple select array with the settings API for a plug-in options page?
- Using register_activation_hook in classes
- Does an activated plugin automatically mean its methods are available to other WP functions?
- Is there a way for a plugin to add an attribute to the tag of a theme?
- Metabox repeating fields – radio buttons not saving correctly
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- Admin Media grid view images won’t load
- Site Title and Tagline in Pagelines DMS Options Panel
- My shortcode is showing up twice
- Database “Migration” for Plugins?
- Does wp-cron runs all tasks scheduled at same time together or one after other?
- Making Quote Plugin more efficient
- How do I use the Simple HTML DOM Parser in plugin when other plugin already uses it?
- Will simple function names in a class structure conflict with other plugins?
- Instantiate class to be available to all plugin functions
- How to test nonce with AJAX – Plugin development
- WP nonce invalid
- Custom filter in admin edit custom post type responding with invalid post type?
- How can i upload images in an admin page?
- How to access global variable $menu inside a class function
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Unreadable pagination
- remove wp floating submenu in wp dashboard
- My custom wp-admin php files stopped working
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- How to upload a file to a folder named after the user_id via plugin
- Reprinting tags with all attributes
- Need Help Fixing My Iframes [closed]
- Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
- Update results, Before deleting the related category [closed]
- adjust section according to country?
- Adding function to Genesis genesis_header [closed]
- Trying to retrieve post meta
- Custom plugin settings link doesn’t append current class to menu item when visited? Why?
- How can I open up my administrative panel to everyone?
- Illegal string offset in PHP function
- How to hook code to show after the_content?
- Using and saving custom dropdown boxes on user profiles
- Problem with AJAX in wordpress plugin
- Override Admin menu icon
- Hooks for post saving make a post-new.php to load latest post’s data
- How can I display Custom Post type Custom Columns and its Content in a Dashboard Widget?
- custom plugin with upload files does not work
- What is the difference between Null vs Empty (Zero Length) string?
- Aspx/Rss feed – failed to open stream: Redirection limit reached
- send popup after wp_redirect()
- no_rest_route error on custom routes
- Checkbox doesn’t save inside metabox
- Adding image upload in tag section – WordPress plugin development
- Create ACF Checkbox to get all ACF Values from Parent Page
- File is executed twice if plugin is activating
- product_type_options get saved value [closed]
- Display a custom name when the user has no name settle in his account
- Sum All the Post Meta of Published posts of Current Logged in user
- How do I remove an action hook inside a class that is called by another class?
- Get post content inside plugin class method
- Autoloading Classes in Plugins
- Admin backend, show post from a category and exclude the posts from subcategories
- Right way to display the_author_meta fields?
- Use page-templates without creating theme
- Comparing Dates within plugin using PHP If statement
- Submit to itself don’t work
- Singleton plugin activation; create database
- custom field meta-box with dropdown/autocomplete
- Repeatable field within repeatable group of fields
- How to get WordPress Adminmenu items?
- How to callback custom field text
- How keep woocommerce users separeted in multisite install and keep admins on network
- Import users and custom user meta from csv
- Prevent users from display default wordpress login form
- Create custom table for wordpress custom registration flow
- Warning: Illegal string offset ‘post’ and ‘page’
- Authenticate + Authorize WP REST API request before built-in WP JSON Schema Payload Validation?
- WordPress wp_set_object_terms does not assign product to custom taxonomy
- How to Customize the Admin Sidebar Menu in WordPress Multisite Network by changing the backend code of the wp-admin code files?