Use different single post page in WordPress

0
5

WordPress, by default  use one “single.php“ for every post. if you want to display a different layout for specific categories  post ?

To Use different single post page we use simple php code in theme “single.php” file.and create category specific single.php files in theme folder.
In the below example lets assume the following:

  • Category 2 is Blog
  • Category 3 is Articles section
  • Category 4 is News section

Create category specific  files in them folder  like as:

single-blog.php  (This file use for Blog category posts )

single-articles.php (This file use for Articles category posts )

single-news.php (This file use for News category posts )

single-default.php (This file use for any post that is not in any of the specified categories (2,3,4) will just use a default template file – “single-default.php”)

Put this code in “single.php” as follows:

 

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here