Created
August 28, 2012 15:07
-
-
Save ericandrewlewis/3498898 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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