freshyill
freshyill

Reputation: 393

Possible to write directly to file with WordPress?

I'd like to get WordPress to write directly to a file. I know I can do this with PHP, but WordPress deals directly with the database, and doesn't do static publishing by default.

I also know there are many caching plugins available, so this may come down to a cache plugin recommendation.

Here's the deal: I'm trying to use WordPress to generate some XML files that I need for another project. So, basically for data entry. Right now, my solution is to have the template put everything I need into a textarea. That's easy enough, but then I have to copy from it and paste that into a text file and save it. I'd love to skip that step and have WordPress make the files for me.

Can you recommend a plugin that would let me do this easily? It's OK if it comes down to a caching plugin, but that seems like it might be overkill. Does something simpler exist?

Upvotes: 0

Views: 2583

Answers (1)

Anonymous
Anonymous

Reputation: 786

get the content of the post and feed it to the fput:

$myFile = "myXML.xml";
$fh = fopen($myFile, 'w') or die("There was an error, accessing the requested file.");
fwrite($fh, get_the_content());
fclose($fh);

Upvotes: 1

Related Questions