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
- Custom plugin: Trying to show saved data on frontend
- Fatal error: Call to undefined function plugin_dir_path()
- How to make WordPress plugin check for database changes and then do something?
- How to use copy() function and paste file in /wp-content/themes directory
- wordpress custom endpoint multiple params
- Create table in database when activating plugin
- Am I not understanding plugins?
- Extend a class of a plugin
- Page Reloads Before AJAX Request Finishes
- Add htaccess rules with insert_with_markers at beginning of htaccess
- Insert array data on plugin activation
- Adding Default Settings to Theme My Login plugin
- Customizer – Prefix Class Extension
- Create onClick Event to Re-load a Widget
- Image media upload metabox
- Hide categories that are not used in the post type
- Automated Cart Update With Alert Box Each Time
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- How to sanitize any integer input field in wordpress?
- WordPress ajax doesn’t display object method on jQuery .change() function
- filter default query to show just selected level of child pages in wordpress
- MetaBox body is not showing (the callback function)
- Adding widgets to my plugin page instead of WordPress dashboard
- How to insert data into database using wp cron job
- WordPress admin is incredibly slow [closed]
- Access Child Class of Plugin Main Class Instance
- Font Awesome changing default WordPress Font
- Download full html page with CSV export plugin
- Why is my custom post type not being activated on plug-in activation?
- How to hook code to show after the_content?
- How can I access string value in an array?
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- Can a plugin redirect product page based on IF condition?
- Save html content of a widget textarea
- How to store multiple custom meta box
- Why does my settings form redirect to the homepage?
- How to override a plugins script
- Woocommerce custom Plugin in wordpress [closed]
- What is the difference between Null vs Empty (Zero Length) string?
- Get options from database using php class
- Post form – AJAX won’t upload featured image – Plugin development
- Fatal error login WordPress [duplicate]
- How can we get this dynamically as this folder may not be by the same name always → wp-admin
- Plugin won’t output characters with diacritics properly
- WP Hook Before a post is created
- ACF relationship on user profile page used for allowed access
- Store user form submitted information in post type
- Problem with my Login Plugin
- How to return html as a string from php for WordPress
- Taxonomy Child Term, Counter is staying on 0
- How to disable sub menu items from being created?
- Access to “My Site” is missing from the admin bar
- add ‘publish metabox’ to Gravity forms edit page/form area
- Need help with format of nested array in MySQL
- How to add delete, approve, spam Links to Comments
- Right way to display the_author_meta fields?
- Help on Wp_query to print an term
- Comparing Dates within plugin using PHP If statement
- Upload images from one server to an other in wordpress
- Setting at job with shortcode not working
- Run code before WordPress loads and insert data into WP if need be
- admin uploads pre_get_posts not working as expected
- PHP: Why does my code work in index.php but not a widget?
- How to use Amazon Elastic Transcoder from WordPress using AWS SDK for PHP?
- Styling admin page rows in order of importance (checkboxes)
- Accessing Variables Used In a Plugin Using PHPStorm + XDebug
- Help with my first Metabox helper class
- Custom Meta Boxes and Fields Multicheck Issue
- Hide sharing box and author box with a metabox on WordPress
- PHP Puzzle: Unique Styles with PHP loop
- I’m not able to get access $wpdb in my php file in wordpress
- Implement OAuth2 in custom plugin
- login redirect based on user role not work as expected
- redirect user from login page if is logged
- How to lock users account until approvation
- Variable ++ in query loop
- How to create a User Role and give permission to only use Web Stories plugin?
- WordPress REST API – Custom field not added to pages