How can I make sure that my_function action hook on 'wp_head' is executing last? One hack, that I'm using, is to give 999999 (a big number) as the third argument. But maybe some other hook on 'wp_head' is giving even bigger number than this one.

function my_function() {
                  background: blue;
add_action('wp_head', 'my_function', 999999);
  • How that function is related to the hook? Dec 24 '13 at 13:39
  • @Chittaranjan sorry, there was a semantic error in the code. It is fixed. I hope that it is now related to hook because of add_action.
    – Omar Tariq
    Dec 24 '13 at 18:21

You define priority. It's not a hack. Maybe it's that you're looking for is PHP_INT_MAX which is a PHP constant. So you can put it as priority number.

  • For example, if my function is hooked with PHP_INT_MAX as priority and another function is also hooked to wp_head with PHP_INT_MAX as priority then what factor will decide that who will execute last?
    – Omar Tariq
    Dec 24 '13 at 18:23
  • 1
    Functions with the same priority are executed in the order in which they were added to the action. Dec 24 '13 at 18:35
  • Chittaranjan is right. It's logically added in the same order when with the same priority
    – JMau
    Dec 25 '13 at 10:38
  • Just a little detail, I don't think he meant that using the priority param is a hack, but rather shooting an absurdly high number in the dark, where he is trying to control with a certain degree of precision that his hook comes last.
    – gloria
    Nov 25 '19 at 17:25

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.