WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to export my database to XML because the import script to my new blog already supports getting data from that. A database backup or wordpress clone is not that useful in this case. The problem is that using the builtin export button times out after 90 seconds. I have ssh access to the server and am not afraid to use it :)

I don't really know php but I can muddle around with help. Given Problem: Create a cron job to export posts to a WordPress XML file on server I think that the export_wp function might be what I want, I just don't know what to do with that...

share|improve this question
It would really be much easier to just configure PHP not to time out after 90 seconds. Or upgrade your db server to get the job done in 90 seconds. Depending on where you're hosting it, both things can be much easier than what you're proposing. – Tomas Buteler Mar 30 '13 at 21:13
Agreed with @tbuteler. If you have ssh access, reconfigure PHP and/or MySQL to have longer timeouts. – s_ha_dum Mar 30 '13 at 21:27
up vote 2 down vote accepted

You guys give up too easily :)

This worked for me:

require(dirname(dirname(__FILE__)) . '/wp-load.php');
require(ABSPATH . 'wp-admin/includes/admin.php');

$xml = ob_get_clean();

file_put_contents('out.xml', $xml);
echo "done"
share|improve this answer
This gives me a 502 error on my WP Engine site. Any suggestions? – jnthnclrk Oct 29 '13 at 20:19

Your Answer


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.