Skip Navigation

[Gelöst] Filter Template depending on CPT

This support ticket is created vor 3 Jahren, 9 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von beateS-2 vor 3 Jahren, 9 Monaten.

Assistiert von: Minesh.

Author
Artikel
#1955171

Please advice how to use query for filtering the assigned template. Example:

If HOBBY = SPORT choose template 1
If HOBBY = ART choose template 2

For that purpose I have created a CPT with two fields. First field = Hobby second field = template.
Thanks you.

#1956063

Minesh
Supporter

Sprachen: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

As I understand, you have created a custom field Hobby where you added some hobbies as option like (Sport, Art) etc..etc.. and assigned this field to post type X.

Now, you want to display different content templates based on the hobby options. If that is true.

Toolset Views offers the filter hook "wpv_filter_force_template" using which you can override the content template.
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_force_template

What you should do is, Create new content template per hobby options and dont assign this content template to any post type.

Then, add the hook to the "Custom Code" section offered by Toolset:
=> > https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

Please check the following related ticket:
- https://toolset.com/forums/topic/set-template-per-post-for-a-custom-post-type/#post-1953569

You just need to adjust the code to respect your hobby custom field options.

#1956335

My issue is resolved now. Thank you!