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

1 Answer 1

1

Where you pass post id ?

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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