Advertisement
Guest User

Preload/Clear pages

a guest
Feb 27th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2.  
  3. // Load WordPress.
  4. require( 'wp-load.php' );
  5.  
  6. // Add one page/post per line
  7. $pages_to_clean_preload =   [
  8.                             'https://example.com/page_url',//copy this line as many times as necessary, adding the URLs you want to clear/preload
  9.                             ];
  10.  
  11. if ( function_exists( 'rocket_clean_post' ) ) {
  12.  
  13.     foreach( $pages_to_clean_preload as $page_to_clean){
  14.         rocket_clean_post( url_to_postid ( $page_to_clean ) );
  15.     }
  16. }
  17.  
  18. // Preload pages/posts
  19. foreach( $pages_to_clean_preload as $page_to_preload){
  20.         wp_remote_get( $page_to_preload );
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement