Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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() {
    ?>
    <style>
        .custom-class{
                  background: blue;
        }
    </style>
    <?php   
}
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

1 Answer 1

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
1  
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

 
discard

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.