0

I've contacted the theme developer but never got a response back... I'm also curious to see if anyone else has done this with any theme.

To give you a live example:

  1. http://demo.powerthemes.club/themes/couponxl/search-page/location/alabama/ , provides viewers deals/offers in the location taxonomy Alabama.

  2. However, web crawlers, etc, can view - http://demo.powerthemes.club/themes/couponxl/location/alabama/ , which looks like a Blog post.

Is there a way to make it so that people viewing a custom taxonomy archive get redirected to the homepage? or, even better, to the actual search page? Do I perhaps have to create a custom archive-template?

thanks!

  • You don't want anyone to see the archive pages? – s_ha_dum Jun 11 '15 at 17:41
  • No, because the archive displays duplicated deals/offers, uses the blog template, and displays expired deals/offers; which is something I didn't want. I posted the solution below :) – Mike Jun 11 '15 at 19:22
0

I added this to my child-theme's functions.php file and it works 100%

add_action( 'template_redirect', 'redirect_archive' );
function redirect_archive() {
    if ( is_tax('location') ) {
        $termurl = get_query_var( 'term' );
        wp_redirect( home_url('/search/location/'.$termurl), 301 );
        exit;
    }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.