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.
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.
My issue is resolved now. Thank you!