WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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);
share|improve this question
How that function is related to the hook? – Chittaranjan 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
up vote 2 down vote accepted

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.

share|improve this answer
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
Functions with the same priority are executed in the order in which they were added to the action. – Chittaranjan 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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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