I'm writing a plugin and having a problem. I have add_action('publish_post', 'sender'); and I want this function to run first before the add_filter function, although it won't. Is there a way to do this? I've tried moving the add_filter below add_action but that doesn't work. Also pasting the add_filter one into the add_action function doesn't work. Thanks for the help.

For example, if this would work it would be great.

  if (add_action('publish_post', 'sender'))

But it doesn't and somehow still runs the add_filter function first.

  • Your question doesn't make a lot of sense. add_action and add_filter both just your functions to the hooks to the system, they don't control the order in which hooks are called.
    – Otto
    Aug 4, 2011 at 19:44
  • in the normal publishing flow wp_insert_post_data is fired by WordPress before publish_post so I'm not sure thats the way to go, what are you trying to do, maybe we can think of another way
    – Bainternet
    Aug 4, 2011 at 19:49
  • 1
    Take a look at the has_action() function.
    – kaiser
    Aug 4, 2011 at 20:13

1 Answer 1


It doesn't matter the order in which you call add_action() and add_filter().

What matters is the order in which the corresponding do_action() and apply_filters() are called.

So, if apply_filters('wp_insert_post_data') is run before do_action('save_post'), tough luck. You'll have to think of another way to achieve the desired result.

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.