What does wp_update_post() do that the $wpdb class does not?

  1. wp_update_post() calls some hooks that $wpdb doesn’t on it’s own. You’ll have to do it on your own to make it compatible with other plugins.

  2. wp_update_post() calls some functions related to database entry sanitation, thumbnails, attachments, time (format, zone etc.), comment, taxonomy, meta, cache etc. So if you use $wpdb, make sure you handle all of them as appropriate.

  3. WordPress will update wp_update_post() to always keep it compatible with the current state of Database, core CODE, plugin support etc. Even if you do everything right, future updates will be difficult for you with $wpdb.

So if something can be done with wp_update_post(), then always use it, only use $wpdb if your desired action related to updating post can’t be done with it.

Leave a Comment