3

Posts may be published either immediately or in the future.

Suppose a plug-in wants to do something at the moment when the post becomes published and visible on the blog (I don't mean when the post is saved as published in the admin panel with whatever date). Is there a hook like "post_visible" or something similar.

1

Every time a post changes status, wp_transition_post_status function will be called. This triggers the actions ${old_status}_to_${new_status} and ${new_status}_${post->post_type}, so for example publish_post will be triggered here. A post with a date in the future will have the status future until it is actually published, so this should work for you.

  • Could you please give an example of the action names . Will the actions triggered be "future_to_published" and "publish_post"? – rsman Sep 8 '10 at 16:03
  • Indeed, publish_post will certainly be triggered, and future_to_publish if the previous status was future (I don't know the initial status if you publish immediately). Mike also gave some interesting hooks in an answer to a related question. – Jan Fabry Sep 8 '10 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.