Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSilviu Panait
11,447 PointsHow do I know the order in which hooks are showing up in execution?
I would like to, for example, add a function to a hook that shows up right after "the_content" gets fired and I cannot find anything on this topic anywhere, can anyone help?
Is the order in which hooks show up in $wp_filter the same order in which they get executed?
Thanks!
1 Answer
Sue Dough
35,800 PointsYou can checkout: https://wordpress.org/plugins/query-monitor/screenshots/
Also
<?php //LIST ALL HOOKS
function dump_hook( $tag, $hook ) {
ksort($hook);
echo "<pre>>>>>>\t$tag<br>";
foreach( $hook as $priority => $functions ) {
echo $priority;
foreach( $functions as $function )
if( $function['function'] != 'list_hook_details' ) {
echo "\t";
if( is_string( $function['function'] ) )
echo $function['function'];
elseif( is_string( $function['function'][0] ) )
echo $function['function'][0] . ' -> ' . $function['function'][1];
elseif( is_object( $function['function'][0] ) )
echo "(object) " . get_class( $function['function'][0] ) . ' -> ' . $function['function'][1];
else
print_r($function);
echo ' (' . $function['accepted_args'] . ') <br>';
}
}
echo '</pre>';
}
function list_hooks( $filter = false ){
global $wp_filter;
$hooks = $wp_filter;
ksort( $hooks );
foreach( $hooks as $tag => $hook )
if ( false === $filter || false !== strpos( $tag, $filter ) )
dump_hook($tag, $hook);
}
?>
and then call it
<?php list_hooks(); ?>
You mainly want to look into priority paramater and change it to fit your needs.