Currently I’ve divided posts into 5 different categories, based on the categories I’ve created 5 page templates. all of the pages are listed into the home page navigation menu. in my home page I’m showing 5 posts in five different categories. when they clicked a post that post will shown in the single page template(that’s what word press normally does) but i want to show that post into my page template. because each page template having different designs. if there is any way to set the permalink to point to the page template and show the post in to full.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The »Template Hierarchy« doesn’t allow this per default.
Inside your single.php template, you can call load_template().
This will allow you to simply include the template you need, based on the in_category() conditional tag.
// inside single.php
if ( in_category( 'foo' ) )
{
load_template( get_stylesheet_directory().'foo_template.php' );
}
elseif ( in_category( 'bar' ) )
{
load_template( get_stylesheet_directory().'bar_template.php' );
}
elseif ( in_category( 'whatever' ) )
{
// ...
}
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0