Is it possible to have more than one content template for a single post?
I have a content template for my post type that displays Fields A, B, C and D.
I would like to have a second content template that displays Fields A, B, E and F.
Ideally, there would be a clickable link from the first content template to the second.
Hi, I can help you apply different Content Templates to posts programmatically, but I'm not quite sure I understand how the links would work. Where is the link shown? Let's say your post URL is https://yoursite.com/book/oliver-twist and this is where content template 1 displays. What exactly happens when someone clicks the link? Is the User directed to a different URL?
Hi Christian
To be honest I'm pretty relaxed about how we would get to the content as I have two different audiences. The post type is a school bus route like this: hidden link
The first audience is general. The content template would have the following fields:
Title > Post body > Bus route description > Bus route map > School bus ID number
This content is available on an 'open' website.
The second audience needs to log in to view some of the content. That content template would have the following fields:
Title > Bus route description > Bus route map > School bus ID number > Bus driver name > Bus driver phone number
Some of that content cannot be shown on an open website.
A third potential use of this data would be:
Title > Bus route map
This content is available on an 'open' website but I want to 'strip back' as much content as possible to make the map working better on a small device.
I'm starting to feel like the best way to achieve this would be to use conditional tags, but I'm looking forward to seeing what you have to say.
Yes, I agree conditional HTML would probably be best here. The overall design will remain consistent across open and logged-in sites, but some data within that design will be shown or hidden based on login status. You can use a conditional to verify the current User's ID. If it's 1 or greater, then you know the User is logged in. If not, you know the User is logged out.
For the third potential use of the data, it depends on where you want to display this stripped down map. If you use a different page on the site to display this information, a separate Content Template specific to that page might be a good idea. Another option is to use a CSS-based approach that shows and hides content based on screen resolution: https://www.w3schools.com/css/css_rwd_mediaqueries.asp
That might be over-complicating things, though, if a separate Page is okay.