Skip to content

Instantly share code, notes, and snippets.

@anthonycole
Created September 17, 2010 00:40
Show Gist options
  • Select an option

  • Save anthonycole/583450 to your computer and use it in GitHub Desktop.

Select an option

Save anthonycole/583450 to your computer and use it in GitHub Desktop.
<?php
add_action('template_redirect', 'wtv_redirect');
function wtv_redirect($url) {
$url = $_SERVER["REQUEST_URI"];
$wines = get_terms( array('wtv_wines') );
foreach( $wines as $wine ) {
if( stripos( $url, $wine ) && stripos( $url, 'category') ) {
wp_redirect( get_term_link($wine, 'wtv_wines' ), 301);
exit;
}
}
$locations = get_terms( array('wtv_locations' ) );
foreach( $locations as $location ) {
if( stripos( $url, $location ) && stripos( $url, 'category') ) {
wp_redirect( get_term_link( $location, 'wtv_locations' ), 301);
exit;
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment