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.

  • 2
    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. Commented May 20, 2014 at 21:03

1 Answer 1


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.


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.