Skip Navigation

[Resolved] Using multiple content templates for a single custom post type

This support ticket is created 3 years, 7 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/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 3 years, 7 months ago.

Assisted by: Waqar.

Author
Posts
#2103649
Screen Shot 2021-07-01 at 12.01.07 AM.png

Hello.
in this post: https://toolset.com/forums/topic/creating-multiple-layouts-to-posts-or-custodia-posts/ Christian Cox states that with toolset, multiple content templates can co-exist for each custom post type.

Reading his response and looking at an actual content template I have a question ...

(see attached screenshot)

in the "Usage" section, in the right hand column of the wordpress block editor, to the right of my custom post type, is a "set conditions" link that pops up the standard Toolset Conditions editor window.

Am I correct in assuming that I can have the system select the content template to use to display a post based on content in an actual post when that post is being added? for example, lets say I have a custom radio button or select field called "Food Type" that has the values "Fruit, Vegetable, Meat, etc..." If the user adds a post called "Hamburger" and indicates that it is a "Meat food type" ... will this cause Toolset to automatically use the Meat Content Template to generate the front-end display of the post as opposed to the Vegetable content template?

Am I correct in this assumption? or am I misunderstanding the usage of that "Set Conditions" popup link

thx!

Gordon

#2103843

Hi Gordon,

Thank you for contacting us and I'd be happy to assist.

Your understanding is mostly correct and this practical usage example will make it more clear.

1. Suppose, your website has a custom post type "Food Items" and it has a custom taxonomy "Food Types" with terms like "Meat", "Vegetable", "Fruit" etc.

2. First, you'll create a default or a fallback content template "CT for Food Items", that will be assigned to all "Food Items" posts without any set condition.

3. Suppose, your goal is to show posts with "Meat" and "Vegetable" terms to show differently from the rest. So, you'll create two new content templates "CT for Food Items - Meat" and "CT for Food Items - Vegetable".

On the content template edit screens for these new templates, you'll select the "Food Items" post type in "Usage" settings the same way as the first template "CT for Food Items". The only difference would be that this time you'll be adding the condition, to use this template only if "Food Type" taxonomy contains "Meat" ( for template "CT for Food Items - Meat" ) and "Vegetable" ( for template "CT for Food Items - Vegetable" ), respectively.

The end result would be that the system will show the posts with the "Meat" term using the "CT for Food Items - Meat" and posts with the "Vegetable" term using the "CT for Food Items - Vegetable".

And for the "Food Items" posts where any of these conditions are not met, the fallback template "CT for Food Items" will be used.

Note: this content template logic will be managed automatically and you won't have to make any changes for this on the edit screen of the individual "Food Items" posts.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar