-
-
Save jasondavis/2570468 to your computer and use it in GitHub Desktop.
Filters for WordPress Template Redirect with Custom Taxonomies and Custom Post Types
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 | |
| /** | |
| * An "easier" interface for interacting with WordPress' template_redirect function. | |
| * | |
| * @package zm-wordpress-helpers | |
| * @uses is_admin() | |
| * @uses get_query_var() | |
| */ | |
| function bmx_race_schedule_redirect( $params=array() ) { | |
| if ( get_query_var('post_type') ) { | |
| $post_type = get_query_var('post_type'); | |
| } else { | |
| global $post; | |
| if ( $post ) | |
| $post_type = $post->post_type; | |
| } | |
| $post_type = 'event'; | |
| if ( $post_type != 'event' ) | |
| return; | |
| $template = array( | |
| 'post_type' => 'event', | |
| 'single' => plugin_dir_path( __FILE__ ) . 'theme/single-bmx-race-event.php', | |
| 'archive' => plugin_dir_path( __FILE__ ) . 'theme/search-bmx-race-event.php', | |
| 'search' => plugin_dir_path( __FILE__ ) . 'theme/search-bmx-race-event.php', | |
| 'taxonomy' => array( | |
| array( | |
| 'taxonomy' => 'attendee', | |
| 'template' => plugin_dir_path( __FILE__ ) . 'theme/attendee-dashboard.php' | |
| ) | |
| ), | |
| 'default' => plugin_dir_path( __FILE__ ) . 'theme/index.php' | |
| ); | |
| do_action( 'zm_template_redirect', $template ); | |
| } | |
| add_action('template_redirect', 'bmx_race_schedule_redirect', 6); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment