The save_post
hook has a third parameter named $update
, so you can use it to check if the post is being created and not updated.
function define_asset( $post_id, $post, $update ) {
if ( $update ) {
return;
}
// else, run your code...
}
add_action( 'save_post', 'define_asset', 20, 3 );
Related Posts:
- How does object caching work?
- How to pass arguments from add_settings_field() to the callback function?
- How to use checkbox and radio button in options page?
- how to update serialized options programatically?
- Performance with autoload and the options table
- Options for CDN with WordPress Including Supporting Plugins?
- Option to set static front page disappeared from admin reading settings
- How to set up default values for a plugin?
- Add on the fly tabs to plugin options
- Plugin options autoloading
- Settings API – changing add_settings_field() output?
- Fallback when Transient API fails
- Submenu pages delete settings from options array when saved
- get_option() from another wordpress site
- Add_settings_field() parameterizing callback?
- Set a Default Value for an Option?
- Setting ‘autoload’ to ‘no’ with Settings API
- Serialized settings in rest api
- Editor role not saving settings page for custom post type
- Can’t output do_settings_sections . Can’t understand why
- Settings API – how to update multiple options manually?
- Settings API – how to update options manually?
- How to change the file upload directory on version 3.5?
- Which WordPress option stores the current active theme?
- update_option method with support of utf8
- How do I add a value to a wp_options option that is an array?
- how can I detect that option value has changed?
- Best practice differences in DB options and wp-config between live, staging and local WordPress environments?
- Logout redirects to a broken page(home URL is omitted)
- Is there a limit to the number of options you can store in one settings field of wp_options?
- wp_user_roles and Advanced Manipulation
- Custom theme options Radio inputs not saving
- Character Encoding for wp_options
- Access general settings trough wordpress files
- get_option & update_option for multiple input fields with same name
- Settings API: Change position of custom setting field
- Clone plugins (and settings) to new installation?
- Can’t save options
- How to cache posts based on $_GET? Option name is too long? Options / transients
- update a value in wp_options [closed]
- Insufficient permissions to save options
- Can we allow users to choose front page from theme options?
- How to display usermeta on front end of site
- save_post_{CPT} not updating the ‘sticky_posts’ option
- settings_fields doesn’t appear to be running
- Settings API – Separating PHP and HTML
- Run function on settings save
- Is there a capability for managing plugin options?
- How to create a drop down list with pages to a themes options page?
- Classes and functions involved in serialization and unserialization
- why is unregister_setting() undefined?
- How to create color scheme for my custom theme?
- Set $options reference
- Settings API validation callback
- Different Front page for Mobile
- How to save user meta on custom admin page
- Is there an optimized, WordPress-y way to not call a `get_option` twice?
- get_option and list of options
- How to retrieve the options from this options page?
- Changing max number of blog posts per page doesn’t work
- Displaying the full text instead of post title
- Add description to custom plugin setting
- Updating just one option with update_option
- Upload file on pre_update_option_{option_name}
- Block properties, attributes and settings
- 403 error on submit at the plugin options page
- WordPress get_option() on AJAX issue
- ‘delete_option()’ only deleting the value, not the key/value pair
- WP Options Query “Rewrite Rules” Taking 10 Seconds After Testing wp_insert_post( )
- If option: show this. Else show nothing
- How can you store your option at the permalink settings page?
- Problem saving wordpress settings with current version. Is it a bug?
- Plugin to import/export wp_options
- Uploading and inserting an image using a custom option panel like in the Twenty Ten theme?
- Drop Down options aren’t saving in my wordpress plugin options page
- Autopopulate a value
- What is the XSSAttack option_name for in the options table?
- WP Optimization: Overwriting options to autoload=yes for often used options?
- How to load WordPress on non WP page?
- Is there a standard technique or API for getting the site header image?
- How to save Checkbox-Options in Plugin Options Page
- Is saving data to WordPress options as array bad thing to do?
- how to compare update_option() after it saves to database?
- centralized alternative for get_option: get_site_option, get_network_option or get_site_meta?
- Some entries delete_option doesn’t work
- Options saved and called in wrong order
- Use delete_option in action link
- Editing a loaded WordPress option without updating the database
- Access saved Options / Settings
- Hold a comment in the queue if it contains [X] or more links
- How do I create settings only used by my theme? [closed]
- Trying to change settings -> firefox downloads options.php instead
- Share content between two different sites in same domain
- how can i add_option as array from a form with just a text input
- wp_allow_comments checking for blacklisted words effectively
- How to add options for Pages?
- options validator input is false?
- Best place to store company address
- Fatal error: Call to undefined function get_option()
- If Home Page Do Nothing, If All Else Show This Content