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 need to import content (daily) from a xml file into wordpress. I am not looking for a specific answer, and I don't expect someone to write the whole code here, I just need some guidance on how to accomplish it.

I plant to:

  1. Write php script to load XML file with simplexml_load_file()
  2. Read the file with SimpleXMLElement()
  3. Put everything in a loop and use wp_insert_posts to create each post
  4. I am going to use ACF for custom fields, not sure if ACF has function to do that programmatically.
  5. Run everything with a cron job

Does the above seems logical? Or am I going about it the hard way. I would appreciate if someone with more experience importing XML files could give me some tips, or things to consider. Thanks.

share|improve this question
Seems logical to me. Check out the ACF documentation (or better yet, check out the source code) - there's a pretty awesome API for manually adding your own custom fields data, so shouldn't be a problem here. – TheDeadMedic May 20 '14 at 21:03
up vote 1 down vote accepted

Sounds like a sound approach to me! Not enough rep to comment so I'm posting an answer... Only advice I'd have is to 1. Make sure character encodings are correct so you don't end up with a bunch of "æÃ" 's 2. Make database backups :-)

As to ACF, I think it's pretty much the same as the "add_post_meta" function. Maybe it has a separate one in its API. But that's easy stuff.

share|improve this answer
Thanks. I will accept it as answer as it confirms my initial question. – gdaniel May 21 '14 at 20:12
Thank you, I am able to comment now :) – Pim May 21 '14 at 20:22

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.