Skip Navigation

[Waiting for user feedback] custom cpt template via URL

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 8 replies, has 1 voice.

Last updated by Minesh 1 day, 22 hours ago.

Assisted by: Minesh.

Author
Posts
#2852580

THello,
Is it possible to assign a template to a CPT created with Toolset via the URL?

I teach cooking classes at a school. Some classes are for aspiring professionals, while others are for amateurs.

I created a “Technology” CPT, which I use to create instructional sheets on various techniques.
A taxonomy assigns this sheet to different levels.
I have created different templates that are displayed depending on the level.
However, some sheets should be usable by both amateurs and professionals (for example, the technique for filleting fish).
Is it possible that:
- If the sheet is accessed from the “amateur” menu, it displays using the “amateur” template
- If the sheet is accessed from the “professional” menu, it displays using the “professional” template

bearing in mind that each of these templates has a different navigation menu, created manually, and different headers.

I hope that’s clear....

In short, what I’d like is to be able to “force” the display of a specific template via the URL or another method, if you have one.

Thank you for your help

#2852604

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Normally - you can set the condition to display the content template conditionally:
- https://toolset.com/course-lesson/assigning-templates-to-posts-conditionally/

There are multiple ways to show the content template, if you can share problem URL and admin access details and tell me with what URL/menu you want to display what content template and once I review that I will be able to guide you in the right direction.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2852689
Exemple_Toolset.jpg
Courscuisine exempple.jpg

Hello,
I'm not sure if I phrased my request correctly. I'll try to be more specific.
In the image below, you'll find two screenshots of my WordPress site using the “Technology” custom post type. The template varies depending on the level (professional courses or amateur courses, plus a few specific subcategories) assigned by a taxonomy.
https://toolset.com/wp-content/uploads/tmp/Courscuisine_exempple.jpg

If I add a link in the menu of Template A to Post B, is it possible to use a URL query (or another method) to display Post B using Template A while retaining Post B’s layout if students access Post B via the menu in Template B?

On the toolset website, there’s something that looks a lot like what I want to do. Depending on the path you take to access a post, the layout is different...
In the image below, I’m using the example from the post you recommended I read about how to dynamically assign a template.

As shown in the image below, the front-end design is different depending on whether I access this post via the lessons or via the training courses

https://toolset.com/wp-content/uploads/tmp/Exemple_Toolset.jpg

That’s actually what I’m looking for: assigning a different template to a post based on the path taken to reach it, rather than just based on a taxonomy.

Sure, I could create as many copies of the post as needed and assign the desired taxonomy to each one, but I’m thinking there might be a smarter way that doesn’t involve unnecessarily duplicating content.

If you think you need access to the site’s backend to provide a solution, please let me know, and I’ll grant you the necessary access.

#2852725

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You can catch the URL param value using the shortcode: [wpv-search-term param='your-url-param']

More info:
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-search-term

And later you can use the conditional shortcode to display the content template as per your requirement.

For example:

[wpv-conditional if="( '[wpv-search-term param='your-url-param']' eq 'url-param-value' )"]
//// show the content template if url-param euqal to url-param-value
[wpv-post-body view_template="content-template-slug"]
[/wpv-conditional]

Where:
- Replace 'your-url-param' and 'url-param-value' and "content-template-slug" with your original values.

More info:
- https://toolset.com/documentation/legacy-features/views-plugin/conditional-html-output-in-views/

What if you can check and see if able solution helps in your case?

#2852746

Hello,

I'm not sure I understand...
Where should I place the code mentioned, and how do I include the desired template in the URL?

#2852844

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - then can you please share details clicking on what link what template you want to display when that clicked linked has what URL param value?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2853209

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I need bit more details.

Please share direct link of the menu and to what menu you want to display what content template. Maybe few screenshots will be helpful. I need informatio like
- Link 1 with required URL param => what template you want to apply.
- Link 2 with required URL param => what template you want to apply.

#2853219
Courscuisine exempple.jpg

https://toolset.com/wp-content/uploads/tmp/Courscuisine_exempple.jpg

Image B :
Template : hidden link
Menu (synchronized) : hidden link

Image A :
Template : hidden link
Menu (synchronized) : hidden link

Post : hidden link

I'd like to be able to create a menu item for Image A so that, when I click on it, the post for Image B appears using the template for Image A

Is this information helpful to you?

#2853224

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked the template you have:
- hidden link
- hidden link

I see you used the grid and you should add container within the 2nd grid cell so whole right part will be within one container.

What I'm on the following post:
- hidden link

Can you please add the link on left site and tell me what link you added and clicking on that link you want to display what template/post?