Skip to content

Instantly share code, notes, and snippets.

@mikeschinkel
Created August 19, 2012 00:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mikeschinkel/3390496 to your computer and use it in GitHub Desktop.
Save mikeschinkel/3390496 to your computer and use it in GitHub Desktop.
WordPress URLs for 1 taxonomy on 2 different custom post types
<?php
/**
* Answering: http://lists.automattic.com/pipermail/wp-hackers/2012-August/044119.html
* By: Mike Schinkel - http://about.me/mikeschinkel
*/
add_action( 'parse_request', 'aeromaxx_parse_request' );
function aeromaxx_parse_request( $wp ) {
if ( preg_match( '#^/(draw-results|ball-statistics)/game/([^/]+)/#', $_SERVER['REQUEST_URI'], $matches ) ) {
$wp->query_vars = array(
'post_type' => $matches[1], // Assumes your post types are registered with same name as your URL slugs
'game' => $matches[2], // Assumes your taxonomy is registered as 'game'
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment