Skip Navigation

[Resolved] parent/child relationship in custom search and post form

This support ticket is created 7 years, 1 month 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
- - 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 1 reply, has 2 voices.

Last updated by Beda 7 years, 1 month ago.

Assisted by: Beda.

Author
Posts
#590758

What I want to attain is this:
Now I have state and city.
In the part of custom search and post form,
I want people who select the state and the only relative city of that state will be showed to select.

I just take the code of Toolset Theme Real Estate as reference.
The post type structure of my site is like this:
Post Type State is the parent of Post Type City
Post Type City is the parent of Post Type House

I think I have some ideas on solving the problem in the custom search.
However, I have no idea on how to do this in post form.

Is there any solution on this situation?
If needed, I can change the structure from post type relationship to Taxonomy parent/child.

Here are the reference links which show what I want to attain. (In the part of filter)
hidden link
https://toolset.com/showcase/

Thanks.

#590827

In a Custom Search you add a Parent Tree Search Field and then in the Custom Search Settings you choose "Let me choose individual settings manually".

There, select "Show only available options for each input".

You will need to choose the whole parent tree in the Custom Filter, not just the direct parent, but also the grandparent.
The ShortCode for the Filter looks similar to this:

[wpv-control-post-relationship ancestors="toolset-grandparent>toolset-parent" url_param="wpv-relationship-filter"]
<div class="form-group">
	<label>[wpml-string context="wpv-views"]Toolset GrandParents[/wpml-string]</label>
	[wpv-control-post-ancestor type="select" ancestor_type="toolset-grandparent"]
</div><div class="form-group">
	<label>[wpml-string context="wpv-views"]Toolset Parents[/wpml-string]</label>
	[wpv-control-post-ancestor type="select" ancestor_type="toolset-parent"]
</div>
[/wpv-control-post-relationship]

As for CRED, I assume you speak about the steps when you create a Child, you want to be able to choose only the parent that is available in it's chosen GrandParent.
(Just as in the Custom Search)
This cannot be done.

CRED allows only the adding of the direct parent when a new post is created.
So you need to have 2 forms, one to create Child Posts and assign to previously created Parent posts.
These can then be assigned as well to grandparent Posts.

The new releases will also make the CRED part MUCH better. I can capitalize this with effort 🙂