Chief Alchemist - Business Consulting For The 21st Century Via A Holistic & Intelligent Approach
Share RSS 2.0 feed for Sign up for the mailing list. Follow Chief Alchemist on Twitter. 'Like' the Chief Alchemist's page on Facebook. See what Chief Alchemist has been Q&A'ing on Quora. Chief Alchemist bookmarks & highlights on Follow the Chief Alchemist on Chief Alchemist channel on Chief Alchemist on Flickr. Mark 'Chief Alchemist' Simchock on LinkedIn. Free Initial Consultation. Email Chief Alchemist. Phone Chief Alchemist.
  • Mark ‘Chief Alchemist’ Simchock
  • 'Email me.Email => ca .at. ChiefAlchemist .dot. com
  • 'Phone me.Alchemy United => 732 997-0028
  • Free initial consultation.Free => Initial Consultation
  • Please be sure to subscribe to your communication channels of choice.
  • Click To Close => The small green (consultation), red (email) or blue (phone) icons in the top upper right.
Business Consulting For The 21st Century Via A Holistic & Intelligent Approach

WordPress dirty little save_post secrets

FYI => The WordPress action save_post isn’t quite what the WP codex makes it out to be. Or at least that’s my current perception. Let me explain…

The first thing worth noting is that the WordPress action save_post fires more than once. That is, the function you call with add_action(‘save_post’, ‘my_function’) is going to fire more than a single time. Yup. Fo’ real. So if you’re using save_post and expecting something to happen once and only once (as I originally expected in this case) you’ll have to add a snippet of to stop after the first cycle. I’ve used save_post before and for some reason this quirk was never an issue, except this time.

OK, not so bad. I found someone else’s snippet and tuned it up for the WP ezClasses library. No biggie.

But here’s where things get a bit too wonky for my tastes. The Action Reference page in the codex specifically says:

“Runs after the data is saved to the database.”

Best I can tell, that’s not true. It fires once before the DB save and then again after. The point being, the snippet I have in place to stop after one save cycle is not seeing the updated post data. Right. Exactly. WTF?!?!

I’ll update the save once snippet to skip Save #1 and use Save #2 but I’m a bit bothered by how something so obvious and important has gone unrevised in the WP codex.

Perhaps it’s just me. Is it just me?

Will not be published. Required.
Please include http://