One simple solution is to check with the query string from the request:
if ( !empty( $_REQUEST['action'] ) && "edit" == $_REQUEST['action'] ) {
/* proceed */
}
But it is also a good practice to use @mmm’s suggestion since you are working with meta boxes where you have the $post
object in use. When composing a new post, there’s an automatically created post with a status of auto-draft
, so let’s proceed the meta box coding when the status is something other than auto-draft
, say publish
for instance:
if ( !empty( ( $status = get_post_status( $post->ID ) ) ) && "auto-draft" !== $status ) {
/* proceed */
}
Glad that helped.
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?
- Adding admin menus to wordpress
- 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
- 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
- Add Custom User Capabilities Before or After the Custom User Role has Been Added?
- Get list of scripts / styles and show file which enqueued them
- Custom attachments uploader code. Almost there!
- $wpdb->insert is changing a value
- What are the default WordPress password requirements?
- The plugin generated 80 characters of unexpected output!
- How to update/auto-update my private plugin? [duplicate]
- Can a plugin be used to contain all custom functions to extend other plugins
- ServerSideRender and Media Object: attributes passing image data object to php renderer even though it’s not set
- Error on inserting a form value to database
- javascript datatables in a plugin
- captcha not working in my custom plugin
- How do I link to a php file in my plugin directory?
- Is it possible to abort post update if specific conditions on metadata are met?
- Remove entire [$key] from array stored in custom field using Ajax – unset($array[$key]); not working
- why do I have to use required parametres?
- plugin content on front-page only. Nowhere else
- Decontruct serialized data array from wp_options
- How to debug new shortcode? And how to get string from shortcode into code?
- plugin modal/popup integration best practice
- append code after the_content not working
- What does $_REQUEST[‘redirect_to’] do?
- how can a plugin return an error message on activation?
- How to get the value entered in the input field in wordpres
- Sanitize and Save metabox values
- Help interpreting @wordpress/create-block-tutorial-template usage error
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- WooCommerce adds a newline symbol (\n) between email recipients
- Upload to a specific media folder created by FileBird Lite
- How can I add a custom button to the post editor?
- How to use register_setting()
- What’s wrong in the WordPress Meta Box Generator code?
- add category id to option name when adding an option on edit_category
- esc_url, esc_url_raw or sanitize_url?
- React Plugin Settings Page Localization
- Is it within WordPress guidelines to update another plugin’s database fields from my own plugin? [closed]
- Block Development: hamburger module throwing error in save function
- How can I chanage the user for the composer container in wp-env?
- Adding a navigation with wp_nav_menu() to a custom block in the site editor
- Why isn’t custom sidebar panel not showing up in the Gutenberg Editor?
- Ninja Forms: Front-End Forms, Post ID?
- Allow HTML in product attributes and variation for WooCommerce
- How do I modify the error code array used by “shake_error_codes” filter?
- How do I add multiple custom menu Woo-commerce my account page?