If your aim is to trigger code when a post is published, as in, the post_status
of the post is set to publish
, then you can hook into save_post
like this:
function cc_publish_wpse_263985( $postid ) {
// check if post status is 'publish'
if ( get_post_status( $postid ) == 'publish') ) {
// do something here
}
}
add_action( 'save_post', 'cc_publish_wpse_263985' );
Related Posts:
- How can I make it so the Add New Post page has Visibility set to Private by default?
- Publish Post After Click On A Link
- how to execute some code after a post is published in WordPress [duplicate]
- Where is the best place to use add_filter
- When can you get current page ID and initialize hooks right after?
- Show Similar Post Titles ( Similar to Stack Exchange )
- How to add option box in “Edit Post” plugin API?
- How do I unlock a post programmatically?
- 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?
- How To Ignore a Filter On Applying Filter the Content In a Function
- Shortcode display outside the div
- How to get posts by content?
- 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?
- Is there an action that is called when a post is restored from the trash?
- How to filter content post only on save
- HELP: Integrating WP with raw PHP code once published button is hit
- How to add inline css/js inside a shortcode
- How to call bind function in wordpress actions or hooks
- Display future posts?
- 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?
- How use %like% in sql statement wordpress
- add_action in functions.php, do_action in plugin?
- Adding Attachment Display Settings in custom media frame
- add action for displaying posts using a shortcode
- ‘wp_login’ action hook not working with wp-login.php file
- Execute a plugin only on post pages
- 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?
- finding whether request is for post, and post id
- How to get all of the activate_plugin action parameters?
- Display post lists in 2nd paragraph
- 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
- Redirect to another page using contact form 7? [closed]
- Add action to fire when a published post is updated
- 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?
- How to get all posts belongs to a user between a certain date
- Hook for page Request?
- Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
- Post status doesn’t update to ‘future’ every time?
- Function added to hook “new_to_publish” not executing – custom plugin
- trigger email when post is published by someone a user follows
- Custom CSS not being added by plugin
- How to use add_action for multiple instances of the same class
- What hook can I use to modify custom post data before it is displayed on the page?
- Delete data from custom table when deleting a post
- Plugin is creating posts twice
- How to write a new file when new post has been published in WordPress
- 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
- How to get Recent Post From Each Category with Thumbnail?
- help intercepting save_post through plugin
- Is it possible to pin a post in second position from top
- Help to Create a Simple Plugin to make a post
- How to display the custom post related blog by category?
- WP Forms not displaying,becomming an fatal error
- Why do actions with class and public method don’t fire __construct()
- The function called on the wp head hook becomes null
- How can I see $post object in frontend from functions.php?
- Allow members to create groups on my site
- add tags to wordpress post using REST API
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- Nested Actions and Filters
- Passing function into add_action always returns the first argument
- Get post content inside plugin class method
- WordPress Product Detail and catalog
- Remove action added in plugin class from theme
- Is it possible to create duplicate post on other site (either push, on publish, or pull, periodically)?
- How can I get the Post ID and Post Type within a Must Use Plugin?
- echo plugin results on pages
- Get content and send to 3rd party
- Displaying friend’s posts only
- Add new post using a page inside the website
- Plugin Hook: Get posts
- Is it possible to cancel a post status transition?
- Get page type to display content
- Capturing POST data
- Custom feed parameters / Template overriding
- How wordpress plugin hooks works? [duplicate]
- Plugin to display text before a post
- warning wp session
- How to trace SUBMIT button
- Can plugin2 uninstall plugin1 at the very beginning of plugin2’s installation?
- Plugin temporary files and files to download via FTP
- Remove List Bullets
- How to set plugin auto-update Enabled by default?
- wp_handle_upload – specified file failed upload test