questions

Create a second single.php file

Rate this post

I’m trying to create a second single.php for my WordPress theme. The first single is used with get_permalink() but it’s impossible to create another single2.php

How is this feasible?

I’d like to use the single2.php the same way as the regular single.php I’ve seen some tutorials but every time they associate the single2.php with the creation of WP categories and I know it’s doable without it. I just don’t know how.

 

✔️Solution:

Open single.php in your HTML editor. Delete the contents of single.php and place the following code in it. Substitute the number 3 for the Category ID # you noted.

<?php
$post = $wp_query->post;
if ( in_category('3') ) {
    include(TEMPLATEPATH . '/single2.php');
} else {
    include(TEMPLATEPATH . '/single1.php');
}
?>

Leave a Reply

Your email address will not be published.

Back to top button