Want to display different single page layouts based on post tag?
-
Have searched the forums but cannot quite find what I am looking for. I am trying to display various page layouts for my single.php file based on if a post is tagged with a certain tag or not. Have tried using is_tag() and an if statement at the top of my single.php template and it does not seem to honor it. So therefore I know I am off teh mark. Here is what I had tried…
<?php if (is_tag('resource')) { ?> Display resource loop here and layout here. <?php } else { ?> Display all others here. <?php }; ?>
The page before this contains a loop of various posts. Do I need to do something to special to the link on that page before clicking into a single post? Feels like it has no clue what the post is tagged with.
Also sometimes the post could be tagged with this as well as others items. I am only interested when the resource tag shows up no matter how many other tags it has.
I considered using tag-slug.php and creating a template but that did not seem like it was for the single post layout but is more designed for a loop of multiple post that have a certain tag.
Any direction and help is much appreciated. Thanks for the time!
- The topic ‘Want to display different single page layouts based on post tag?’ is closed to new replies.