When a WordPress filter or action doesn’t behave the way you expect — “my callback isn’t running”, “the value gets overwritten”, “the order is wrong” — the diagnostic isn’t a guess. There are tools that show the full hook execution timeline. The trick is knowing which one fits which question.
What’s happening
WordPress hooks are stored in the global $wp_filter array. Each entry is a hook name pointing to an array indexed by priority (default 10), each priority pointing to an array of callbacks. When do_action('save_post') runs, WordPress walks that array in priority order, calling each callback. A do_action returns nothing; an apply_filters returns whatever the last callback returned.
The places things go wrong: a callback registered too late (after the hook already fired), a callback registered with the wrong number of arguments, a filter that returns null instead of the value it received (so the next callback gets null), two callbacks at the same priority and the second overwrites the first, or a callback that’s silently never reached because an earlier one short-circuited via return false.
How to verify
# Print all callbacks attached to a hook:
wp eval 'global $wp_filter; print_r($wp_filter["save_post"] ?? "no callbacks");'
# Use Query Monitor's Hooks panel — shows every fired hook in execution order
# Add temporary logging:
add_action('all', function($hook) {
error_log("HOOK FIRED: $hook");
}, 1);
For a single hook, use the did_action debug pattern:
add_action('init', function() {
error_log('init fired at priority ' . current_filter() . ' - count: ' . did_action('init'));
}, 1);
Query Monitor’s Hooks panel is the fastest read for “which callbacks ran for this hook” — it shows callback, priority, source file, and execution time.
The fix
- Use Query Monitor first. Hooks panel, find the hook in question, expand to see every callback in firing order with priority and source. If your callback isn’t there, registration failed.
- Confirm registration timing. A callback registered in
plugins_loadedwon’t catch hooks that fired earlier (duringmuplugins_loadedor initial config). Register on the earliest hook you can. - Check argument count.
add_filter('my_filter', 'my_callback', 10, 3)— the3is critical. If your callback declares three parameters butadd_filtersays1, the extras come through as null. - Check the return value. Filters must return what they received (modified or not). A filter that does
return;returnsnulland the next callback seesnull. Usevar_dumporerror_logon the return. - Use
allhook for full trace. Attach a callback to theallhook to log every fired hook. Useful for “which hook should I be using” questions. Remove it before production. - Use
HookrorDebug Barfor deep dives. These plugins show even more detail than Query Monitor, including hooks that fired but had no callbacks attached.
For plugin and theme development across distributed teams, Stack Harbor enforces hook discipline as part of managed enterprise WordPress hosting code review. To get a hook conflict diagnosed, book a consult.