Skip to content

Instantly share code, notes, and snippets.

@matgargano
Last active January 3, 2016 09:29
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 matgargano/8443539 to your computer and use it in GitHub Desktop.
Save matgargano/8443539 to your computer and use it in GitHub Desktop.
<?php
add_filter('query_vars', function($vars){
$vars[] = 'customendpoint';
return $vars;
});
/* set up rewrite rule */
add_action('init', function(){
add_rewrite_rule('(customendpoint)$', 'index.php?customendpoint=true', 'top');
});
/* if customendpoint is set redirect */
add_action('pre_get_posts', function($query){
$custom_page = get_query_var('customendpoint');
if ( $custom_page ) {
include(get_stylesheet_directory() . '/customendpoint.php');
die;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment