Skip to content

Instantly share code, notes, and snippets.

@toby-griffiths
Last active December 26, 2015 07:59
Show Gist options
  • Save toby-griffiths/7119231 to your computer and use it in GitHub Desktop.
Save toby-griffiths/7119231 to your computer and use it in GitHub Desktop.
WordPress - How to redirect a custom post type's single page to a taxonomy page
<?php
function wp9899234_parse_query() {
if ( is_admin() || is_single() || '<post_slug>' !== get_post_type() ) {
return;
}
// Work out taxonomy page
// $tax_permalink = ...?
wp_redirect( $tax_permalink ); exit;
}
add_action( 'parse_query', 'wp9899234_parse_query' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment