In my previous post I talked about a Lorelle blog post on creating single post templates for different categories.
After using the code snippets “as is” I tryed to build a more flexible solution so I’ve come up with this little function:
1 2 3 4 5 6 7 8 9 10 | |
This function must be called inside the single.php template: it gets the first post’s category, searches for a template named like singlepost_first_category_slug.php and returns its path; if the file doesn’t exists it will return the single_default.php_ template path.