Multiple Single.php File In WordPress
All posts on your WordPress site will be published using the single.php template. The single.php file is used when you click on the post title on the Home Page or Archive Page of the site, and you will see just the single post.
In WordPress, we can use only one single.php. But sometimes we need different single pages for different categories, where you want the single post page to look different.
:
Question is how to do that?
You can solve this problem with conditional statement.
First, you have to note down the category ID.
Second, copy your signle.php and rename it single-photo.php, single-video.php and single-default.php.
Now you have 4 single.php files in your theme folder.
Open your single.php and delete all codes inside the file and put this code below:
<?php $post = $wp_query->post; if ( in_category(‘3′) ) { include(TEMPLATEPATH . ‘/single-photo.php’); } elseif ( in_category(‘4′) ) { include(TEMPLATEPATH . ‘/single-video.php’); } else { include(TEMPLATEPATH . ‘/single-default.php’); } ?>
Upload to your server all the single.php files and see the change…
That’s all.