0

I having a problam with my wordpress plugin. The plugin does whenever new post has been published, it will automaticly create a new file with that post content.

this is my code

function example($post_ID) {
    global $post;
    $content = htmlentities(get_post_field('post_content', $_GET['post']));
    file_put_contents(dirname(__FILE__) . '\myFile.txt', $content);
}
add_action('publish_post', 'example');

But when i change the code some think like this. this will working

file_put_contents(dirname(__FILE__) . '\myFile.txt', "Some string here");
1

Where you pass post id ?

 $content = htmlentities(get_post_field('post_content', $post_ID));
| improve this answer | |
  • 1
    Oh my god.... WOW... finaly it works... thanks a lot man.. u saved my time. :) – Mifas Apr 27 '12 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.