Hooks sequence problem
-
Function hooked on pre_get_posts is executed before a function hooked on init action.
I’ve checked WordPress actions sequence and init action is triggered before pre_get_posts, so my logic is functions hooked on init should be executed firstly against functions hooked on pre_get_posts.
I’ve installed a plugin which shows the sequence of executed actions and the init action is executed firstly, which is okay.
I tried to debug it, but unfortunately without success. Here is my debugging flow:
I’ve checked with xdebug breaking points the sequence of actions and functions execution. I set 4 breaking points:- do_action( ‘init’ ) at line 353 in wp-settings.php
- do_action_ref_array( ‘pre_get_posts’, array( &$this ) ) at line 2396 in query.php
- function A which executes on init
- function B which executes on pre_get_posts
The result is:
- do_action( ‘init’ ) is called firstly
- do_action_ref_array( ‘pre_get_posts’, array( &$this ) ) is called secondly
- and the strange part is here function B is called before A
- Function A is called after B
So what can be the reason function B is called before A?
Thank you in advance!
- The topic ‘Hooks sequence problem’ is closed to new replies.