Skip Navigation

[Resolved] Custom Post Type with Sub Post Types / Relationships with Specific Custom Fields

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to create "sub-types" within a post type, and display different sets of custom fields depending on which subtype is selected.

Solution: You could accomplish this with conditional field display based on other custom field values, Content Template selection, and so forth.

Relevant Documentation:
https://toolset.com/documentation/user-guides/types-custom-fields-conditional-display/

This support ticket is created 5 years, 8 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1219074

I've created a similar setup to my current project before but I wanted to see the best way to set up a specific custom post type (Properties Listings) in toolset with multiple "sub-types" that would then have specific custom fields depending on that type.

The Basic hierarchy is Properties with specific types or category (Retail, Office, Multi-Family, Industrial) and then within each of those types there would different custom fields tied to each, as well as setting up a custom content template.

For example, specific custom fields on a multi-family property wouldn't be relevant to a lease property, so setting up the type would allow an admin to only choose to custom fields relevant to that type (Retail, Office, Multi-Family, Industrial). And then within those, the option to have either Sale or Lease.

All of these would still fall under Properties and have one main Archive where all the fields would be searchable / filterable. The breakdown of categories (Retail, Office, Multi-Family, Industrial) is mostly only for being able to have exact custom fields tied to each on the backend as well as selecting a content template for each. I know there are post relationships & also intermediary types, as well as setting up custom taxonomies that are hierarchical.

What would be the most efficient way to set this up using toolset? The specific sub-types will not need their own permalink or url / archive on the frontend, they will all be in the same "properties" archive page / view. Again, this is more for backend use of selecting specific custom field per type & also being able to select a content template tied to that subtype.

Appreciate the help!

#1219150

Just wanted to add, I also am wondering if simply having conditionals on custom fields specific to that type would suffice.

Basically, having an initial dropdown / select field to select the type and then once that type is selected a conditional group of custom fields for each type would then appear. The constant fields that would be included on each type (location, area, etc.) would be the same on all types but content specific for that type would be filtered by conditionals.

And the correct content template would still be able to be chosen to have that specific type styled correctly on the fontend.

Thanks!

#1219254
Screen Shot 2019-03-21 at 2.30.03 PM.png

Hi it sounds like you only need one post type / archive, but you need specific fields or field groups to appear, conditionally based on some other arbitrary criteria. Types offers the ability to manage the display of individual custom fields, or entire custom field groups, based on several other criteria. Individual fields can be dependent upon other individual custom field values. Field groups can be dependent upon post type, selected Content Template, specific taxonomy terms selected, or other custom field values (see the attachment). We have more information about that available here: https://toolset.com/documentation/user-guides/types-custom-fields-conditional-display/

In your case, since Content Templates will be different per "subtype", that may be a practical way you to set up your field dependencies. Or, like you said you could have some static fields for all subtypes including one radio or select field up at the top that is used to determine the rest of the fields. Either could work...but if you are planning to use Forms to create posts, the Content Template selection criteria won't be effective on the front-end (there's no Content Template selection in Forms). So that's one limitation to consider.

#1219294

Great, thanks Christian, I appreciate it.

I think using data-dependant field groups with custom fields within those groups per property type makes the most sense. Because of the forms limitation, backend access to create listings will be necessary and shouldn't be a problem. The content template selection is definitely a necessity, as each type will be styled differently.

I had one more quick question about the custom fields, specifically repeatable fields. For properties there will be specific spaces available with a square footage, and some properties have multiple spaces that need to be added. Would this be best achieved with a Repeatable Group, for example "Available Space" with then all the custom fields related to that specific space (square footage, suite, etc.). Then create a view that filters by that repeatable fields group and place it inside a content template?

I've ran into a few issues with the repeatable fields in a view if the repeatable fields have the same value for a radio button selection and messing up the styling on the content template.

Thanks!

#1219296

Sorry but I don't have a very clear idea of what you want to accomplish and the problems you're trying to avoid based on the information I have here. Since we're drifting off the topic of data-dependent custom field display, my suggestion is to create a separate ticket that includes some rough mockups or screenshots of what you want to achieve, the problems you want to avoid, and any other relevant information. We can discuss in more detail and come up with the best approach. Thank you!

#1219333

Sorry about that Christian, I will definitely create a separate ticket for the repeatable fields & setting up that view with some screenshots to discuss further. Thanks again!

#1219335

My issue is resolved now. Thank you!