Skip to content

Instantly share code, notes, and snippets.

@jchck
Created June 16, 2015 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchck/19313691f1c4d2371ce8 to your computer and use it in GitHub Desktop.
Save jchck/19313691f1c4d2371ce8 to your computer and use it in GitHub Desktop.
/**
* @link http://cfxdesign.com/remove-unused-css-from-wordpress-automatically-with-grunt
*/
function show_sitemap() {
if(WP_ENV === 'development' && isset($_GET['show_sitemap'])) {
$the_query = new WP_Query(array('post_type' => 'any', 'posts_per_page' => '-1', 'post_status' => 'publish'));
$urls = array();
while($the_query->have_posts()) {
$the_query->the_post();
$urls[] = get_permalink();
}
die(json_encode($urls));
}
}
add_action('template_redirect', 'show_sitemap');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment