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
- Objective Best Practices for Plugin Development? [closed]
- add_menu_page() with different name for first submenu item
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- How to include PHP files in plugins the correct way
- How can I add an image upload field directly to a custom write panel?
- A tool to analyze rewrite rules? [closed]
- Difference Between Filter and Action Hooks?
- framework for plugin/theme options panel? [closed]
- Creating a table in the admin-style?
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- Settings API with arrays example
- How to get the path to the current theme?
- How to make a plugin require another plugin?
- ajaxurl not defined on front end
- What process do you use for WordPress development? [closed]
- What’s the difference between term_id and term_taxonomy_id
- Should I use wpdb prepare?
- Why does WordPress use outdated jQuery v1.12.4?
- Post meta vs separate database tables
- Is there any plugin development framework
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How to add a javascript snippet to the footer that requires jQuery
- Enhance Media Manager for Gallery
- How do I create a custom role capability?
- How do I add CSS options to my plugin without using inline styles?
- How do i best handle custom plugin page actions?
- Adding Custom Text Patterns in the WP 4.5 Visual Editor
- Automatically determine minimum WordPress version required for a plugin?
- What is the advantage of using wp_mail?
- How to make a WordPress plugin translation ready?
- How many times will this code run? (or, how rich is grandma?)
- How to create an API for my plugin?
- Is it ever okay to include inline CSS in plugins?
- Plugins in symlinked directories?
- How to override existing plugin action with new action
- How to include a file using get_template_part() in a plugin?
- Add custom TinyMCE 4 Button, Usable since WordPress 3.9-beta1
- How to store username and password to API in wordpress option DB?
- body_class hook for admin pages
- “Error: Options Page Not Found” on Settings Page Submission for an OOP Plugin
- Is it mandatory to use $wpdb->prefix in custom tables
- Which hook should be used to add an action containing a redirect?
- add_action hook for completely new post?
- Why does WordPress add 0 (zero) to an Ajax response?