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

While a specific use-case, I believe this may benefit others.

I am using TurboCSV to mass-import a number of posts into WordPress (which it is doing wonderfully so far). Within that import, I am specifying custom fields to be used in conjunction with Advanced Custom Fields to store/output the data. The post_meta table is being created correctly, but the part that is not working as expected is generating ACF's hidden fields (which work with field relationships). When the import is first done, those database tables are not created until you manually go into each post and re-save them. I was wondering if there is a way to "fake" the onSave event for WordPress for a number of posts. ACF also passes along post information (stored on the post edit screen) to this save function - which makes it a bit trickier - but I'd be interested if anyone has any thoughts. Thanks!

share|improve this question
Gosh -- I was hoping someone would've answered this question. Did you ever come up with a solution yourself? I can't tell you how many times I've needed to go into every custom post type on my site and simply re-save them to reformat some ACF data that I've changed the structure of. It would seem like there'd HAVE to be a way to automate this.. (BTW, odd, but I realized I just started following you on Twitter the other day, and here we are wondering about the same problem. Kismet! ) – user19035 Aug 8 '12 at 2:31
See my comment below - may be a good work-around for you as well :) – Zach Aug 9 '12 at 12:36
up vote 2 down vote accepted

Have you seen wpshell? It's a command line tool for wordpress. Basically, it's a Wordpress environment that lets you run arbitrary php - so you could set up a WP_Query that pulls all posts, loop through them, and fire that command on each one.

Sort of what I had in mind, untested. Using wp_update_post() as it contains the save_post hook, and is the equivalent of hitting 'update' on the post edit screen:

$args = array('posts_per_page' => -1, 'post_type' => 'any')
$query = new Wp_query($args)
while ( $query->have_posts() ) : $query->the_post();
    echo $post->ID . '<br />';
echo 'Done!  Everything saved!';
share|improve this answer
Ah very interesting. One possible workaround I think will work (while still a bit time consuming), is to use fakeapp.com What I can do there is create a repeating action in FakeApp that runs through each post ID (that I specify from the range that is imported) and then does the saving on each one. I can then take a nap while it does the work for me ;) – Zach Aug 9 '12 at 12:31
I don't see how that's quicker or easier than using an automated tool built for WordPress, but to each their own. – SickHippie Aug 9 '12 at 23:18
No I definitely agree - was just offering up what I had found thusfar. I'll definitely give wpshell a shot. Thanks! – Zach Aug 9 '12 at 23:54
No problem - you could also put this code into a template file and run from there. Create a page /resave (with the slug resave), make a copy of page.php called page-resave.php put this code in place of the loop, and load that page. You should see it iterate through a list of post numbers (it will skip revisions and CPT's that are marked exclude_from_search). And THAT would be quick and easy. :) – SickHippie Aug 10 '12 at 16:39
Awesome! Now let's say that when the post is saved, it uses $POST data to write to the hidden fields stored in the database (that's how Advanced Custom Fields does it), does wp_update_post() simulate that data? That's the only reason I was going the "Fake App" way to ensure that information was there. – Zach Aug 10 '12 at 16:42

I know this is an old ticket, but data importing is an ongoing challenge for users, I am sure!

I've recently started using WP All Import, and I came across the same problem with ACF fields. Luckily, they came out with an extension for the plugin for exactly this problem:


WP All Import ACF Add-On should handle this conundrum no problem. It is a premium plugin, but I use it almost monthly, so it has more than paid for itself. Hope this helps someone.

share|improve this answer

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.