Title: Custom code on Post
Last modified: August 19, 2016

---

# Custom code on Post

 *  Resolved [artcoder](https://wordpress.org/support/users/artcoder/)
 * (@artcoder)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/custom-code-on-post/)
 * I want to add some custom PHP code so that whenever the user publish a post, 
   WordPress will write the post title to a text file on the webserver. I know how
   to write file in PHP. I just don’t know where to insert this PHP code into the
   WordPress framework.
 * If you point me to reference or tutorial, I can figure it from there.

Viewing 1 replies (of 1 total)

 *  Thread Starter [artcoder](https://wordpress.org/support/users/artcoder/)
 * (@artcoder)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/custom-code-on-post/#post-1122053)
 * I found it [here](http://codex.wordpress.org/Function_Reference/add_action).
 * It goes something like …
    `add_action('publish_post', 'yourfunction');`

Viewing 1 replies (of 1 total)

The topic ‘Custom code on Post’ is closed to new replies.

 * 1 reply
 * 1 participant
 * Last reply from: [artcoder](https://wordpress.org/support/users/artcoder/)
 * Last activity: [16 years, 9 months ago](https://wordpress.org/support/topic/custom-code-on-post/#post-1122053)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
