WordPress: Redirect to Taxonomy

By Aaron on May 27, 2014
In rare situations, removing the WordPress single page format (single.php) and redirection to a parent such as a taxonomy can have massive advantages, especially if you have continuously expiring content.  This is a solution I came up specifically for use with The Couponic. Coupons are their own post type (coupons_type) and this code redirects them […]

In rare situations, removing the WordPress single page format (single.php) and redirection to a parent such as a taxonomy can have massive advantages, especially if you have continuously expiring content.  This is a solution I came up specifically for use with The Couponic.

Coupons are their own post type (coupons_type) and this code redirects them to a Store based Taxonomy

This quick solution which can be added to your themes functions.php file:

[box] // COUPONIC COUPON CUSTOM POSTS
add_action( 'template_redirect', 'redirect_single_coupon' );
function redirect_single_coupon()
{
is_singular( 'coupons_type' )
and wp_redirect( '../',301 )
and exit;
}[/box]

 

Article written by Aaron