Skip Navigation

[Resolved] Create more than one content templates for a single post

This thread is resolved. Here is a description of the problem and solution.

Problem:

I have created a Custom Post Type and a Content Template for these posts.
What if I need to show these posts through a second Content Template?

Let's say that I create a View, that only certain users can see, and when they click on each post title they can load this post, but they can see completely different fields and layout than what all other users see?

Solution:

There are two workarounds, see details here:
https://toolset.com/forums/topic/create-more-than-one-content-templates-for-a-single-post/#post-1077219

Relevant Documentation:

https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by katerinaA 6 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1076549

Hi, this is a theoretical question, so I don't have a link to use as an example.

I have created a Custom Post Type and a Content Template for these posts.
What if I need to show these posts through a second Content Template?

Let's say that I create a View, that only certain users can see, and when they click on each post title they can load this post, but they can see completely different fields and layout than what all other users see?

Is this possible?

Thank u for your time.

#1077178

Hello,

I suggest you use Toolset Access plugin to create a custom user role for those users, in the post content, display different content for different user role:
https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/

#1077180

Hi, thanx for your reply.
Yes, this is the "obvious" way, but let's not focus on the different content per user, but on the possibility to have different content depending on the "views template" that someone sees and then clicks on the post.
So, i.e. I create a view which displays all my posts and when I click on any post it links to a page with "title, subtitle and featured photo".
And I also create a view which displays all my posts but when I click on any post it links to a page with "title, body and photo gallery".
Is this achievable? Is there a way to have two different displays for the same post?

#1077219

There are two workarounds:
1) Without custom codes, you can try these:
a) Create two content templates, for example:
- Content template for user role A, display ""title, subtitle and featured photo"."
- Content template for user role B, display ""title, body and photo gallery"."
b) Create another content template, for example "Post content template", assign it to single post, in this content template, display different content template (A or B) for different user role
https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/

2) With some custom codes, use Views filter hook "wpv_filter_force_template" to change the content template ID according to current user's role, more help:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_force_template
and other thread to get user role of current user
hidden link

#1077258

Excellent suggestions!

Thank you very much, I'll just play around a bit! 🙂