0

I currently have a custom post type called 'Services' which has two levels (parent and child).

I need to load three different templates within this post type (1 for the parent, and two different ones for the children'.

Can anyone please explain how I might go about achieving this?

Any suggestions would be greatly appreciated.

1

1 Answer 1

1

All sorted. For any one interested, I simply added in a function (into functions.php) that redirected to my new template dependent on the name of the post (you could also use the ID).

add_filter('template_include', 'new_template');

 function new_template($template){
       global $post;
       if($post->post_name == 'mortgage'){
           $template = get_template_directory() . '/mortgage-template.php';
       }
       return $template;
 }
3
  • You should not be using template_redirect here. Use template_include as I suggested in my comment Commented Oct 3, 2014 at 8:57
  • +1 for posting your solution. Remember to visit this answer again after two days to accept it. :-) Commented Oct 3, 2014 at 9:15
  • Previous answer wasn't working so have updated the working version. Thanks again. Commented Oct 3, 2014 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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