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
- $wpdb->insert writes a record twice for some reason, when my custom developed plugin calls my class function once
- 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?
- Using OOP in WordPress Plugin Development
- Query String being Removed Creating a Pagination Issue within a Custom Plugin
- PHP can I add line numbers to file_get_contents()
- Shortcode Inside Class Not Working
- Add htaccess rules with insert_with_markers at beginning of htaccess
- custom shortcode will not display the wrapped content
- How to call function at the bottom of post using plugin?
- Register non hierarchical taxonomy and the show meta box in the post type
- Admin username and password
- White Screen of Death – wp-admin
- How to restrict wp generate attachment metadata() to certain intermediate image sizes
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- Admin notice not displaying
- Insert array data on plugin activation
- Will simple function names in a class structure conflict with other plugins?
- Do my defines need to be unique?
- WordPress php filter admin_body_class not working
- How to get media objects
- Instantiate class to be available to all plugin functions
- Common abstract class for plugins
- Customize Plugin
- Applying OO patterns and principles to plugin development
- How to test nonce with AJAX – Plugin development
- What does $wpdb->get_row return?
- Use object in template part
- Can’t extend some core classes
- WP add_action factory
- wp_loaded hook block script enquequing
- WP nonce invalid
- Retrieving Author ID in wp-admin area
- woocommerce subscriptions – get expiration date [closed]
- Same log message keeps on printing to debug.log file thousand of times
- database interactions using OOP
- Adding Default Settings to Theme My Login plugin
- Custom filter in admin edit custom post type responding with invalid post type?
- WordPress Scheduled Event Request Blocking
- How can i upload images in an admin page?
- Append HTML Using Shortcode
- Delete a WordPress transient from a shortcode on Page/Post update
- Plugin CSS not enqueing
- Customizer – Prefix Class Extension
- Create onClick Event to Re-load a Widget
- Swapping wp_dropdown_categories function with wp_category_checklist
- Accessing the database from a plugin outside of action hooks
- Adding subdomain to home_url for “add_menu_page”
- How to show phpinfo() only in a new tab?
- How to find error in my code when the error message is pointing to WP core file?
- How to create a form and display its content as table in admin panel?
- Extending the WP_Widget_Text class
- 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?
- Image media upload metabox
- Namespace spl_autoload problem in WordPress admin
- Trying to get property of non-object “ wordpress ”
- Loop with slider (slider not loading)
- Linking text within textarea of custom meta box
- Hide categories that are not used in the post type
- Automated Cart Update With Alert Box Each Time
- How can I remove a function that has been added to wordpress with add_filter?
- Unreadable pagination
- remove wp floating submenu in wp dashboard
- PHP Fatal error: Uncaught mysqli_sql_exception: Table doesn’t exist in wordpress/wp-includes/wp-db.php
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- How to sanitize any integer input field in wordpress?
- My custom wp-admin php files stopped working
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- How to prevent XSS alter custom global javascript object & methods in WordPress
- WordPress ajax doesn’t display object method on jQuery .change() function
- Custom user login page by creating a plugin
- Singelton class does not work, multiple initialization on page reload
- Saving an array of dynamic repeater data as post_meta
- what is the best practice to add new field to an api route
- filter default query to show just selected level of child pages in wordpress
- Call to undefined function wp() in wp-blog-header.php
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)