This hook is called like this:
do_action("{$new_status}_{$post->post_type}", $post->ID, $post);
My guess is that you should be using data passed as second $post
argument, rather than global.
So:
add_action('publish_post', 'publish_post', 10, 2 );
function publish_post($post_id, $post) {
// stuff
Related Posts:
- dbDelta not creating tables
- How to fork a plugin?
- Where to store PHP files created by plugin / themes
- Default table collation on plugin activation?
- How to implement color picker from wordpress in my plugin?
- Nonces can be reused multiple times? Bug / Security issue?
- WordPress 4.5 deprecated get_currentuserinfo()
- Single Responsibility Principle and WP Classes
- How to control output of custom post type without modifying theme?
- Admin config screen without menu
- How to auto-upgrade my plugin?
- How to Add a .js file Only in one specific Page Dynamically to Head
- What is the added “complexity” of custom tables?
- Displaying search results in the widget itself?
- Missing “category_children” option when dynamically creating categories via a plugin
- How to exclude content (and other returned values) from WP_query()?
- Looking for callback function after Gutenberg is rendered?
- WordPress select dropdown list in widget
- Call to undefined function get_blog_option()
- How to duplicate a curl XML request using HTTP API?
- Unable to get content from $post on first publish
- Broken markup when using the_excerpt() in a widget?
- 404 errors after plugin options update and category base change
- Gutenberg Block add element in the Editor inside InnerBlocks after div – editor-block-list
- How to determine, from plugin script, if active theme has The Post Title
- Widget Admin – Form Submit Event?
- How to add pages to custom menus on the fly [duplicate]
- How can I add a CSS rule to edit.php?
- How do you render_callback for register_block_type to a method in another class?
- Get the password key when using the wp_new_user_notification_email filter
- WordPress API have Plugin Anti-piracy feature?
- WordPress security issue to output data from user input from theme option form
- How to add settings subpage from a plugin to a settings page created in theme?
- how to add Jquery script to one page?
- how do you prevent showing a particular category on the admin dashboard for specific user roles?
- how query string in wordpress receive the value other than post and page [duplicate]
- Is there no admin ui guide for 4.x?
- Is there an event or an other method that tells me the preview is loaded?
- Admin Plugin POST to another file within the plugin
- Do I have to worry about useState causing a re-render?
- user_register not triggering with email verification
- Widget Dropdown doesn’t working
- Why is the WordPress taxonomy not registering?
- mysql_real_escape_string() vs. esc_sql() in WordPress
- Display list of uploaded images, filtered by user under a specific user group
- Checking for existence of a page by title?
- pagination in a custom list created with get_pages function
- Bug: Post needs to be updated twice when adding action for save_post hook
- How to enqueue scripts in right way in a plugin?
- Plugin AJAX Save to Custom Table
- Why enqueue styles on hook?
- Encoding Method for URLs?
- Store custom meta box data as serialized array
- Using Product variations as product addons
- Change author permalink to external URL
- How to get post meta in functions?
- AJAX request not routing through proxy
- Custom Settings Plugin Save foreach checkboxes
- Rewrite not working since upgrade to 5.9
- Why won’t this submenu page show? – My First WordPress Plugin
- wordpress full site editing problem when extending core blocks
- How to check if `comment_meta` exists before inserting the comment?
- Showing results from json-string in WordPress search results page
- Multiple dynamic Tax Query – pass taxonomy argument from array
- Add default custom taxonomy to plugin activation
- ACF Field value in wordpress login message filter
- ajax stopped working when not logged in wordpress
- How to revive (or take over) a plugin?
- Make visible page only in the trash
- Overriding the template files using a plugin for all themes
- Woocommerce product not appearing in category list page when created programatically [closed]
- add_meta_box does not display meta box in Admin
- Using meta_key & meta_value in add_rewrite_rule
- implementing socket.io with wordpress
- Custom Registration Form and Passwords
- Determine if the current page, is being edited
- List Table action argument not cleared
- What is the “best” way to update a theme via a plugin?
- Fullwidth slider using background image Flexslider WordPress
- Return value of $wpdb->update() query in plugin is wrong
- Acessing WP functions in form submission handler
- Plugin files not updated (cache cleared)
- How to limit the number of posts a user can view based on status
- WordPress permalink setting
- Error when trying to save custom post type settings (ERROR: options page not found)
- Developing a plugin, ran it through P3 Profiler, shows up slow, but I don’t know why
- Dynamic banner for use on external sites
- How to add additional field in a table row after creating a table?
- WordPress plugin tables become corrupt
- How to call a new php page inside a plugin page?
- How can i call from custom fields to the category editor?
- Practical Solutions to HTML5 Video on WordPress
- An adiitional function fires on my AJAX submit
- Is it possible to convert various image types from remote URLs to WebP and then serve them immediately?
- If I want to create new taxonomies (e.g. Project / Documents / Etc…) is it better to create them in the theme’s functions.php or within a plugin? [duplicate]
- How to add something after a function
- Is the only way to add taxonomy terms via an admin panel?
- Reinitiate Gutenburg’s blocks using javascript
- Generating Multiple Divi Pages from Database
- Is it smart to require_once wp-admin/includes/plugin.php when you need only one function from it