Skip to content

Instantly share code, notes, and snippets.

@ericandrewlewis
Created August 28, 2012 15:07
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 ericandrewlewis/3498898 to your computer and use it in GitHub Desktop.
Save ericandrewlewis/3498898 to your computer and use it in GitHub Desktop.
<?php
add_action('init', 'register_gallery_endpoint');
function register_gallery_endpoint() {
add_rewrite_endpoint( 'gallery', EP_PERMALINK );
}
add_action('template_redirect', 'catch_gallery_endpoint');
function catch_gallery_endpoint() {
global $wp_query, $post;
// if this is not a request for json or a singular object then bail
if ( isset( $wp_query->query_vars['gallery'] ) && is_singular() ) {
$post = get_queried_object();
locate_template('gallery.php', true, true);
exit;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment