Please can someone update this code for me as TEMPLATEPATH is deprecated.
<?php
$post = $wp_query->post;
if ( in_category('advice-and-ideas') ) {include(TEMPLATEPATH . '/single-advice-and-ideas.php');}
elseif ( in_category('travel') ) {include(TEMPLATEPATH . '/single-travel.php');}
else {include(TEMPLATEPATH . '/single-default.php');
}
?>
John Cotton answers:
<?php
$post = $wp_query->post;
if ( in_category('advice-and-ideas') ) {include( get_template_directory(). '/single-advice-and-ideas.php');}
elseif ( in_category('travel') ) {include(get_template_directory(). '/single-travel.php');}
else {include(get_template_directory(). '/single-default.php');
}
?>
Hey Jules!
julesphoto comments:
Bingo! Thanks John.
Hariprasad Vijayan answers:
Hello,
<?php
$post = $wp_query->post;
if ( in_category('advice-and-ideas') ) {include(get_template_directory(). '/single-advice-and-ideas.php');}
elseif ( in_category('travel') ) {include(get_template_directory(). '/single-travel.php');}
else {include(get_template_directory(). '/single-default.php');
}
?>
Arnav Joy answers:
try this
<?php
$post = $wp_query->post;
if ( in_category('advice-and-ideas') ) {include(get_stylesheet_directory_uri(). '/single-advice-and-ideas.php');}
elseif ( in_category('travel') ) {include(get_stylesheet_directory_uri(). '/single-travel.php');}
else {include(get_stylesheet_directory_uri(). '/single-default.php');
}
?>
Navjot Singh answers:
<?php
$post = $wp_query->post;
if ( in_category('advice-and-ideas') ) {include(get_template_directory() . '/single-advice-and-ideas.php');}
elseif ( in_category('travel') ) {include(get_template_directory() . '/single-travel.php');}
else {include(get_template_directory() . '/single-default.php');
}
?>
Use this
Remy answers:
Using get_template_part is better than include
<?php
$post = $wp_query->post;
if ( in_category('advice-and-ideas') ) {get_template_part( 'single-advice-and-ideas.php');}
elseif ( in_category('travel') ) {get_template_part('single-travel.php');}
else {get_template_part('single-default.php');
}
?>