Skip Navigation

[Resolved] How to use CPT Parent posts as filters for Child posts of same type?

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 3 replies, has 2 voices.

Last updated by Beda 7 years, 5 months ago.

Assisted by: Beda.

Author
Posts
#535048
Practice Areas.jpg

I am trying to: Configure a view that (a) displays all "Practice Areas" CPT parent posts in a single select filter, and (b) returns the child posts of the selected parent.

I visited this URL: Edit View > Filter Editor > New Filter > Post Relationship

I expected to see: Option to add "Practice Areas" CPT post parents as filter

Instead, I got: "Before using a post relationship filter, you need to set a Types parent-child relationship for the post types selected in the Content Selection section."

The parent-child relationship documentation (https://toolset.com/documentation/user-guides/creating-post-type-relationships/) seems to only address situations where the Parent CPT and Child CPT are different CPTS.

In our case, the parent and child are the same CPT ("Practice Areas" - see attached screenshot) .. and we can not find any references for how to create a parent filter that returns children of the same post type.

Specifics:

We are working with an existing custom post type called "Practice Areas". There are 150 Practice Area custom posts in the WP database. These custom posts are organized hierarchically into 15 top level Practice Areas with approximately 10 child Practice Areas each.

The resulting structure is as follows:

Top Level Practice Area 1
- Child Practice Area 1
- Child Practice Area 2
..
- Child Practice Area x

...

Top Level Practice Area N
- Child Practice Area 1
- Child Practice Area 2
..
- Child Practice Area z

...

In other words, some Practice Areas are parents with children that are also Practice Areas.

We want to build a view where (a) the parent practice areas are all displayed in a single select filter, and (b) the child practice areas of the selected parent are returned by the view.

How can we accomplish this?

Thanks!

#535148

1. In our case, the parent and child are the same CPT

This is impossible.

I think you mean the WordPress page hierarchy, which you can also enable for CPT's created with Types.

2. For this kind of relationship you cannot create a Custom Filter.
You can thou add it as a Query Filter, but this is not a Front End Filter.

3. I will ask the Developers why we did not include this as a Custom Filter as well, I think it would make sense to do so.

#535270

Thank you Beda.

<quote>1. In our case, the parent and child are the same CPT

This is impossible. I think you mean the WordPress page hierarchy, which you can also enable for CPT's created with Types.</quote>

Yes you are correct I was indeed referring to the WordPress page hierarchy.

As a work around I decided to add a new taxonomy to the CPT and use the taxonomy to filter the CPT. The filtering now works as desired; but now I'm having problems setting a default term for the taxonomy filter.

It appears that Views allows you to add a "default" filter option to wpv-control-post-taxonomy but it apparently defaults to select "All" and can not be set to a particular term in the taxonomy.

Since I took a new approach I opened this ticket to request assistance:

https://toolset.com/forums/topic/help-with-setting-taxonomy-filter-default-to-a-particular-term-in-taxonomy/.

Can you take a look at that ticket? Or do you want to address it in this ticket?

Thanks Beda

#535426

I will take a look there and keep this here as a reference to the new feature for the Filter I mentioned above.

Thank you for your exceptional understanding and patience.

The forum ‘Types Community Support’ is closed to new topics and replies.