WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this function below that is called with the admin_init Action

function my_flush_rewrites() {
    global $wp_rewrite;

Like this

add_action('admin_init', 'my_flush_rewrites');

I am curious, when is this called? Is this called on every page load? Hopefully not

share|improve this question
up vote 2 down vote accepted

From the Codex:

admin_init is triggered before any other hook when a user access the admin area. This hook doesn't provide any parameters, so it can only be used to callback a specified function.

So yes, it's run on every admin page load.

share|improve this answer
Yeah I had read that but I wasn't sure, so basically my average user won't be hammering this over and over, that is all I was afraid of, thanks for the quick response! – JasonDavis Apr 19 '12 at 4:06
You shouldn't put flush rules call to admin_init precisely as it's run everytime one loads a admin page. Instead run it when activating, deactivating a plugin, or if the plugin has settings page the when you save the new settings. – Ciantic Mar 6 '14 at 15:33

All the hooks are executed after the core WordPress application completes its loading process.

So initialization hooks are mainly used to initialize the process in plugins and themes.

Available init hooks in WordPress, in the order of their execution are -

1)init -> runs after WordPress has finished loading but before any headers are sent. Generally, this used by plugins to initialize their process.

2)widgets_init -> is used to register sidebar widgets of the application. The register_widgetfunction is executed within this hook.

3)admin_init -> is executed as the first action, when user access the admin section of WordPress. Generally, it’s used to initialize settings specific to the admin area.

admin_init hook runs every time admin page is rendered.

You can also look into Wordpress Codex for more information about activation process.

share|improve this answer

Your Answer


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.