Skip to content

Instantly share code, notes, and snippets.

@Rarst
Created September 26, 2017 12:04
Show Gist options
  • Save Rarst/7798021bc3fe905a517f08bdbe224621 to your computer and use it in GitHub Desktop.
Save Rarst/7798021bc3fe905a517f08bdbe224621 to your computer and use it in GitHub Desktop.
<?php
add_action( 'template_redirect', function () {
if ( ! isset( $_GET['crash'] ) ) {
return;
}
$urls = [];
$urls[] = home_url();
$urls[] = home_url( '404' );
$posts = get_posts( [
'numberposts' => 1,
'fields' => 'ids',
] );
if ( ! empty( $posts ) ) {
$urls[] = get_permalink( $posts[0] );
}
$pages = get_posts( [
'numberposts' => 1,
'fields' => 'ids',
'post_type' => 'page',
] );
if ( ! empty( $pages ) ) {
$urls[] = get_permalink( $pages[0] );
}
var_dump( $urls );
die;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment