wordpress on publish hook

// Add this to your theme's functions.php file function my_function_name( $post_id ) { //...Your code here } add_action( 'publish_post', 'my_function_name' ); The code above creates a custom function in WordPress that is triggered when a post is published. It then hooks this function to the publish_post action in WordPress, allowing it to be executed when a post is published.