Custom Post pages

Description

This code will allow you to create unique looking post pages depending on the category of the post. In order for this to work the PHP code must be placed in a file called single.php. Inside this code are 4 different post templates   These 4 templates must also be in the file directory, otherwise […]

This code will allow you to create unique looking post pages depending on the category of the post. In order for this to work the PHP code must be placed in a file called single.php. Inside this code are 4 different post templates

  • single-one.php
  • single-two.php
  • single-three.php
  • single-default.php

 

These 4 templates must also be in the file directory, otherwise the post template will automatically adopt single-default.php.

PHP Source Code

                        
                          <?php
$post = $wp_query->post;

if ( in_category('1') ) {
include(TEMPLATEPATH . '/single-one.php'); } 

elseif ( in_category('2') ) {
include(TEMPLATEPATH . '/single-two.php'); } 

elseif ( in_category('3') ) {
include(TEMPLATEPATH . '/single-three.php'); } 

else {
include(TEMPLATEPATH . '/single-default.php');
}
?>                        
                        


Post Categories