Title: Auto Refresh Admin Page
Last modified: February 3, 2017

---

# Auto Refresh Admin Page

 *  [yuanfamily](https://wordpress.org/support/users/yuanfamily/)
 * (@yuanfamily)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/auto-refresh-admin-page/)
 * Is there anyway that I can auto refresh a single admin page? Backend pages such
   as order listing would be nice to auto load. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/auto-refresh-admin-page/#post-8733050)
 * You can execute this javascript to reload the page:
    `window.location.assign(
   window.location.href);`
 * But something needs to trigger it. Add an event listener perhaps?
 * To get your script loaded call wp_enqueue_script() from a callback hooked to “
   admin_enqueue_scripts” action.
 * The problem will be the browser will reload from its cache instead of fetching
   the page from the server. When the page initially loads we need to send a Cache-
   Control header telling the browser not to cache the page. This can be added in
   the “wp_headers” filter, but depending on several factors, this may not work 
   without further adjustments to other headers, .htaccess, httpd.conf, etc.
 *  Thread Starter [yuanfamily](https://wordpress.org/support/users/yuanfamily/)
 * (@yuanfamily)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/auto-refresh-admin-page/#post-8734319)
 * Thanks for the reply, bcworkz.
 * If it is a regular HTML page, I can use meta refresh tag to refresh. However,
   for a plugin which calls edit.php?post_type=<something>, how do I add any meta
   or javascript?
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/auto-refresh-admin-page/#post-8736052)
 * To get your javascript loaded call wp_enqueue_script() from a callback hooked
   to “admin_enqueue_scripts” action. To add tags in the head section, one way is
   to hook the “admin_head” action and output the tag from the callback. This will
   be just before the closing </head>. Checkout wp-admin/admin-header.php for other
   possible hooks that fire earlier.
 * In some cases you can selectively control which page the hook fires for by determining
   the value for $hook_suffix of the page you are targeting. In other cases any 
   conditional application needs to be done within the callback.
 * I imagine the meta refresh will have the same cache issue that the script does.
   As you are likely aware, there is also a no-cache meta tag you could use. Managing
   it through headers is preferable IMO, but trickier to code.
 *  Thread Starter [yuanfamily](https://wordpress.org/support/users/yuanfamily/)
 * (@yuanfamily)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/auto-refresh-admin-page/#post-8738174)
 * Thanks again for the reply, bcworkz.
 * I am a java guy, I know HTML too, but this is the first time I tried to customize
   a wordpress plugin. When user navigates to [http://<domain>/wp-admin/edit.php?post_type=<something&gt](http://<domain>/wp-admin/edit.php?post_type=<something&gt);,
   how does it generate the order page? Where and how to I put the hook?
 * I really appreciate your detailed help.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/auto-refresh-admin-page/#post-8739108)
 * edit.php first loads admin-header.php, which handles all the head section content.
   It then fetches an instance of the WP_Posts_List_Table class. The object’s prepare_items()
   method is called, which executes a query for appropriate orders. The the display()
   method is later called which loops through the query results and outputs the 
   orders for the page.
 * The code I’ve been referring to needs to be placed somewhere safe from updates.
   Your only reasonable options are your own custom plugin or a child theme of your
   chosen theme. You can also place all future custom code you might come up with
   in the same place. I’ve found that once one learns how to tweak things in WP 
   through hooks it’s hard to stop! There will be more custom code in your future
   🙂

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Auto Refresh Admin Page’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 5 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/auto-refresh-admin-page/#post-8739108)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
