Title: Hooks sequence problem
Last modified: August 30, 2016

---

# Hooks sequence problem

 *  [Jordan Enev](https://wordpress.org/support/users/jordan_enev/)
 * (@jordan_enev)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/hooks-sequence-problem/)
 * Function hooked on **pre_get_posts** is executed before a function hooked on **
   init** action.
 * I’ve checked [WordPress actions sequence](https://codex.wordpress.org/Plugin_API/Action_Reference)
   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:_
    1. do_action( ‘init’ ) at line 353 in wp-settings.php
    2. do_action_ref_array( ‘pre_get_posts’, array( &$this ) ) at line 2396 in query.
       php
    3. function A which executes on init
    4. function B which executes on pre_get_posts
 * The result is:
    1. do_action( ‘init’ ) is called firstly
    2. do_action_ref_array( ‘pre_get_posts’, array( &$this ) ) is called secondly
    3. **and the strange part is here** function B is called before A
    4. 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.

## Tags

 * [init](https://wordpress.org/support/topic-tag/init/)
 * [pre_get_posts](https://wordpress.org/support/topic-tag/pre_get_posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Jordan Enev](https://wordpress.org/support/users/jordan_enev/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/hooks-sequence-problem/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
