Multiple views of a single post
-
Hi guys,
I hope this is the right place for this question as it doesn’t really fall into any of the other categories.
I’m a long time WordPress developer however I have a unique request. I have a client who wants 2 different views of each post in a custom post type.
I know how to build a template for each view on it’s own and I also know how to show different content in the one single-$posttype.php template depending whether the user is logged in or based on their IP location etc.
However my client would like two different views of each post which are both available to every visitor on 2 different URL’s. To my knowledge wordpress can only show one single post view for each post as only one URL is generated by the core.
Eg. “Sample Post” of custom post type “posttypex” would have two different views:
1. The standard wordpress view here: ourdomain.com/posttypex/sample-post
2: A secondary view something like this: ourdomain.com/posttypex/sample-post-landing or ourdomain.com/posttypex/landing/sample-postWe can’t duplicate the posts themselves in the same post type as only one version is to show on the custom post type archive page. Plus that’s highly inefficient.
I have been googling (nothing found) and racking my brain and I can think of two methods to achieve this and I don’t like either of them:
Method A: Add a query parameter and show different content in the template when this paremeter is present. Eg. ourdomain.com/posttypex/post-a?view=landing
Method B: Create a new post type posttypey and create a duplicate post for each primary post in posttypex then have a custom field as the only content in posttypey to assign the posttypex version. I would then write a custom query in single-posttypey.php to essentially find the assigned sibling post and pull the relevant content from there.
Does anyone have a better solution? Any ideas at all?
Thanks very much,
Nicole
- The topic ‘Multiple views of a single post’ is closed to new replies.