Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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");
share|improve this question
    
If you want a question migrated, ask the moderators. I flagged your first question on SO – stackoverflow.com/q/10338875/299509 – for migration. –  toscho Apr 27 '12 at 10:50

1 Answer 1

up vote 1 down vote accepted

Where you pass post id ?

 $content = htmlentities(get_post_field('post_content', $post_ID));
share|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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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