• nicole2292

    (@nicole2292)


    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-post

    We 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

    • This topic was modified 4 years ago by nicole2292.
Viewing 2 replies - 1 through 2 (of 2 total)
  • catacaustic

    (@catacaustic)

    Adding a query parameter is the best way. It will make it easy to see which template to use, and will also let search engines see it as a single page instead of two separate but indentical pages.

    Thread Starter nicole2292

    (@nicole2292)

    Thanks so much for your feedback @catacaustic . However you’ve made me realise that the query parameter approach is no good for exactly the reason you mentioned. Google would not index the pages separately in that case.

    The entire reason the client wants the different views is for SEO purposes so we certainly need search engines to see two entirely different pages on two different URLs. The content will be reasonably different on each version however it will be ultimately sourced from the original post which has many custom fields and complex relationships with other posts on the site.

    Thanks,

    Nicole

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple views of a single post’ is closed to new replies.