As an alternative, you can make use of the ‘transition_post_status’ hook for this. This hook is fired whenever a post’s status is changed. In your case, you need to check whether the old and new status of the post is the same, which is publish
You can also set conditionals according to $post, which is the current post being updated/published etc.
You can try the following:
add_action('transition_post_status', function ($new_status, $old_status, $post) {
if ( $old_status == 'publish' && $new_status == 'publish' ) {
//Do something when post is updated
}
}, 10, 3 );
Related Posts:
- Where is the best place to use add_filter
- When can you get current page ID and initialize hooks right after?
- Using the ‘draft_to_publish’ hook (post status transition)
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- How can I limit functionality in one version of a plugin?
- Shortcode display outside the div
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- Can a plugin add to header/footer/body content?
- Is it possible to add an action to the currently running action?
- Action on post publish
- How to add inline css/js inside a shortcode
- How to call bind function in wordpress actions or hooks
- How to prevent action in ajax request, when in admin side?
- template_redirect not being called when using ajax
- add action wp_head not working
- What are the benefit in adding hook in the init() hook?
- add_action in functions.php, do_action in plugin?
- add action for displaying posts using a shortcode
- ‘wp_login’ action hook not working with wp-login.php file
- Any hook for pre-plugin-update -either bulk or single plugin update
- wordpress plugin is not activating from widget
- When to load auto-login code?
- How to get all of the activate_plugin action parameters?
- How to check current user before all actions and filters?
- Get Time Taken By Each Action Hook in WordPress
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Custom plugin init action causing general slowness
- Inject HTML meta tag inside wordpress tag using add_shortcode
- How to pass variables to a function argument using add_action [duplicate]
- Submit Form data to another page via Ajax (WordPress Way)
- Does using `add_action( ‘init’…` cause performance issues?
- Hook for page Request?
- Custom CSS not being added by plugin
- How to use add_action for multiple instances of the same class
- How to append new form elements in “Add New” form of Users in WordPress admin panel?
- I cannot include a file in my plugin settings page
- Why do actions with class and public method don’t fire __construct()
- The function called on the wp head hook becomes null
- Nested Actions and Filters
- Passing function into add_action always returns the first argument
- Get post content inside plugin class method
- Remove action added in plugin class from theme
- echo plugin results on pages
- Plugin Hook: Get posts
- Is it possible to cancel a post status transition?
- How wordpress plugin hooks works? [duplicate]
- add_action() not working for admin
- Does a plugin’s “main” file need to be named the same as the folder containing it?
- Customizing subject in comment notification e-mails
- enqueue script only if it is not already enqueue
- Plugin child folder?
- Retrieving plugin options value saved through setting
- How to ‘clone’ a wp plugin to make small changes
- How to slice an array using posts_per_page? [closed]
- Enqueue WordPress plugin scripts below all other JS
- woocommerce payment gateway callback not firing [closed]
- White page by using filter template_include
- Is there any kind of theme on WordPress to sell my own movies?
- Customization API for plugin development
- User switching only with specific role and return
- Fromcraft Plugin On click submit button [closed]
- Which file of wordpress manage plugins functionalities?
- WordPress error: Options page Setting_ not found in the allowed options list
- Translations for my plugin don’t show up
- flush_rewrite_rules() not working with update_option_{$option}
- WooCommerce: after install hook
- How to ignore extra whitespaces in translation functions like _e?
- How does translation (gettext) work for translating config file of plugin?
- how to add a comment button to be displayed only for the posts in the home page [closed]
- The “Child Pages Shortcode” plugin, block template
- using wp_footer hook in a plugin
- How to get a custom page through plugin?
- How to data add to table when update post wordpress? when we clicked!
- can’t unzip file
- WooCommerce – I want to add functionality of one plugin to another plugin — best approach?
- Want to create custom design of progress indicator in wpforms
- How to display the custom post related blog by category?
- WP Forms not displaying,becomming an fatal error
- How to create a page with the selected template after activating the plugin
- I enabled debugging but I still get the same message: There has been a critical error on your website
- wp_mail function not working in WordPress Plugin Boilerplate
- When/where would want to attach other classes to the base class in a WordPress plugin?
- Using foreach loop for `$instance` of form and update array widget iteration
- Could someone maybe point me in the direction of a decent tutorial on how to create a wordpress plugin that is compatible with another plugin please?
- Custom plugin which downloads updates from custom endpoint, extracts new version zip into a new name
- wp meta_query meta_value compare =REGEXP delimited by space
- Create shared actions for admin and users with plugin bolierplate
- How to insert variable which contain array value in wp_options table?
- How to Insert images in WordPress using code
- shortcode which is introduced into entry the blog, and appears in side bar
- Multiselect value in wp_query
- How to Overwrite validate_plugin function
- how to load a file from a plugin when a url is passed
- Form data to wordpress DB
- Register additional wp plugin directory
- How to display blog posts only authored by the administrator
- Send email notification when meet the condition
- Cannot edit Sidebar in any theme in wordpress
- how to update wordpress plugin programmatically using plugin path
- Testing Plugin – Install plugin dependencies in testing enviroment