Advertisement
miriamdepaula

WordPress: Parse request hook - 1 tax for 2 custom post type

Aug 20th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Answering: http://lists.automattic.com/pipermail/wp-hackers/2012-August/044119.html
  4.  * By: Mike Schinkel - http://about.me/mikeschinkel
  5.  */
  6. add_action( 'parse_request', 'aeromaxx_parse_request' );
  7. function aeromaxx_parse_request( $wp ) {
  8.   if ( preg_match( '#^/(draw-results|ball-statistics)/game/([^/]+)/#', $_SERVER['REQUEST_URI'], $matches ) ) {
  9.     $wp->query_vars = array(
  10.       'post_type' => $matches[1], // Assumes your post types are registered with same name as your URL slugs
  11.       'game' => $matches[2],      // Assumes your taxonomy is registered as 'game'
  12.     );
  13.   }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement