Showing different single.php’s based on authors?
-
I was reading a guide on how to show different single.php-files by using the original single.php only as a navigation wheel with a small code that pointed to other “single.phps” (but with new names of course) based on what category they were posted in.
I wanted to do exactly the same based on authors instead of categories. (The reason being I want to show different ads depending on which author wrote a post).
With categories the code in single.php would look something like this:
<?php $post = $wp_query->post; if (if_category('2')) { include(TEMPLATEPATH . '/single_version1.php'); } elseif (if_category('3')) { include(TEMPLATEPATH . '/single_version2.php'); } elseif (if_category('4')) { include(TEMPLATEPATH . '/single_version3.php'); } else { include(TEMPLATEPATH . '/single_original.php'); } ?>
Based on this code, I tried to use “if_author” but that didn’t seem to work at all. So then I found out that “is_author” was probably more correct, and yes, things looks good, but they are still not showing. Only the “single_original” after the “else”-thing is showing, on every post, no matter which author wrote it.
Am I doing this wrong or is this not possible with authors?
- The topic ‘Showing different single.php’s based on authors?’ is closed to new replies.