Created
August 19, 2012 00:16
-
-
Save mikeschinkel/3390496 to your computer and use it in GitHub Desktop.
WordPress URLs for 1 taxonomy on 2 different 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 | |
/** | |
* 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