template redirect function for single php?
-
I have a custom post type in my child theme (of 2011). It’s added by a plugin. The single items are displayed in single-product.php and that works very well. But my problem is I need to display 3 different types of product and I want 3 different single templates. I wondered if I could do something like check for a certain taxonomy like cats, dogs or mice and then send it to a different version of my single template, like single-product-dogs.php?
I found this on another site, can’t remember where now, I’ve been looking for ages…
function my_template_redirect() { global $wp; if ($wp->query_vars["taxonomy"] == “example”) { include(TEMPLATEPATH . “/taxonomy-example.php”); die(); }} add_action(“template_redirect”, ‘my_template_redirect’);
It looks like what I want to do but I’ve no idea where I should put it. Would this go in single-product.php or does it go in the functions file? And if it would work how do I add the other two choices to the function?
I’d be gratefull for any ideas!
- The topic ‘template redirect function for single php?’ is closed to new replies.