Skip Navigation

[Gelöst] Using custom fields in multiple Ppst types?

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.

This topic contains 4 Antworten, has 2 Stimmen.

Last updated by christianN-4 vor 10 Monate, 1 Woche.

Assigned support staff: Minesh.

Author
Artikel
#1767697

Hello,
I have a question about using the same data for different custom post types. To explain more in detail. I have a custom post type "projects" with different custom fields. Now I want to use some of the projects as "case studies" therefor I need some additional custom fields and some control to make this visible as "case study". So I thought of adding these cutstom fields to the project post type and just add the missing fields to this. So I thought to of adding some kind of radiobox also like "This is a case study "yes / no". And if it is set to yes the project will also be displayed case study but in a different template.

Is this even possible? Or is my approach correct?

#1768249

Minesh
Supporter

Languages: Englisch (English )

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

Hello. Thank you for contacting the Toolset support.

Yes - this is possible.

To display the field conditionally based on your checkbox "This is a case study "yes / no", You can use the Toolset's "Conditional Backend Display for Custom fields":
=> https://toolset.com/course-lesson/custom-fields-conditional-display/

And as you said, you want to display different template if the checkbox "This is a case study "yes / no" is checked, you can use the Toolset View's filter hook: wpv_filter_force_template
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_force_template

#1771583

Thanks for your reply! Thats good to hear. I just got one Problem. The other post type template was initially created with elementor and not with toolset view. As I need the same page layoit O fear that I must stick with elementor template. I it possible to use the view filter from toolset anyway?

#1771585

Minesh
Supporter

Languages: Englisch (English )

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

To trigger the hook "wpv_filter_force_template" you will require to create content template with Toolset.

You did not mention before that you are using the Elementor template.

As you are using Elementor template, I suggest you should check with Elementor support about how you switch elementor template dynamically based on some condition (I mean as per your requirement).

#1782457

Thanks for your reply. I am thinking of an other approach now. Is it possible to create a new custom post type “case studies” and connect an existing project to this? That way i could just add some additional custom fields and create a template for this post type. I am not sure if elementor can read the values from a connected post?