3

There is a save_post hook that is run when you save a post. In fact, revisions and autosaves also call this hook. Even if you simply change the status from published to draft it triggers the save_post hook.

Is there any way (using normal wp methods) that a post could be modified without calling save_post? (like editing custom fields)

I'm wondering if I need to tie into transition_post_status or updated_postmeta or if save_post is enough.

4
  • Please clarify what you are actually trying to do. From your comment to an answer here, I understand that there is some misunderstanding.
    – kaiser
    Sep 17, 2014 at 20:38
  • @kaiser, there is no misunderstanding, Johannes answered the question.
    – Xeoncross
    Sep 17, 2014 at 20:46
  • 2
    Sure there was one: I misunderstood that it wasn't the solution :)
    – kaiser
    Sep 17, 2014 at 20:47
  • I linked to a codex article of a core function, when the OP meant a (yet another) action hook (run within said function), @Vienna. Sep 17, 2014 at 21:29

1 Answer 1

6

TL;DR: No, you can use save_post. Unless you consider programmatic modification of only metadata "modifying a post".


There (theoretically) is a way of modifying a post without triggering the save_post action hook: Direct modification of the database.

But for one no plugin or theme author in his right mind would go that route and for another it would circumvent all other possible action hooks as well.

The other hooks you mention are for entirely different use-cases:
update_post_meta or updated_postmeta run only when metadata is changed, i.e. not when only title or content are edited.
transition_post_status will not run when a published post is merely edited.

Iff you consider programmatic updates of post metadata a modification of the post itself you will indeed have to tie into the update_post_meta hook or the like as well. The update_post_meta() function calls update_metadata() (source on trac) which will run several action hooks (see linked source), but indeed not save_post.

2

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.