Created
May 23, 2013 17:16
-
-
Save micalexander/5637739 to your computer and use it in GitHub Desktop.
wordpress:snippet:endpoint print
This file contains hidden or 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 | |
| // Register "Print" Custom Endpoint, e.g. /listing/mylisting/print/ via http://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/ | |
| function az_add_print_endpoint() { | |
| add_rewrite_endpoint( 'print', EP_PERMALINK ); | |
| } | |
| add_action( 'init', 'az_add_print_endpoint' ); | |
| function az_print_endpoint_redirect() { | |
| global $wp_query; | |
| // if this is not a request for print or a singular object then bail | |
| if ( ! isset( $wp_query->query_vars['print'] ) || ! is_singular() ) | |
| return; | |
| // include custom template | |
| include(locate_template('template-print-listing.php')); | |
| exit; | |
| } | |
| add_action( 'template_redirect', 'az_print_endpoint_redirect' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment