1285934434_WordPress

WordPress Magic- Different post page for different category post

Hello Friends !! Since last many time, I am working with wordpress and I got lot of challenges with wordpress customization.

Recently, I have a confusion that how can I make different single.php file for different posts ? After long research, I got a solution of this problem.

You can create as many single.php files as you want and you also can apply it to different posts. For example, In your site News section has a different layout then blog posts. At that time, this post helps to you .

Here I give you example that how you can do this.

First , create one file called single-categoryID.php in theme folder.

After creating this please go to single.php, file which shows you full article.

for more details click below:

After header, write below code:

if (in_category(‘9’))
{
include (TEMPLATEPATH . ‘/single-9.php’);
}
elseif (in_category(’10’))
{
include (TEMPLATEPATH . ‘/single-10.php’);
}
else
{
rest of the code…….
}

You can create as many templates as you want. You can also create multiple headers like this and include like a\same above code.

Thats It !! Enjoy different template for different posts.

If you have any wordpress customization query or any confusion, feel free to ask me or comment me.

Thanks,

  • http://www.programmingfacts.com Rakshit Patel

    Really useful. Thanks a lot.

  • phpgenious

    Thanks Rakshit.
    Keep commenting.

  • anonymous

    Copy & pasted content……
    nothing new