Skip Navigation

[Resolved] parametric search with filter by parent attributes

This support ticket is created 7 years, 11 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 18 replies, has 2 voices.

Last updated by Minesh 7 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#405678

I am trying to: insert a filter into a parametric search of a child CPT which enables the user to filter on the basis of fields of the parent CPT.

to make it clear. Companies (parent CPT) make announcements (Child CPT).

A field in the Companies CPT is "state" - with multi-select

when viewing announcements made by all companies I wan the user to be able to filter by the state of the company making the announcement.

can you please suggest how I can achieve this?

cheers

Peter

#405707

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Could you please try following steps:

1. Child view named "Child view - listing announcements"
- Content selection: post_types= announcements
- Add Query Filter:

Post relationship filter
Select posts that are a children of the Post set by parent View.

- Add all your desired fields to display in loop output section

2. Parent view named "Parent view - listing Companies"
- Content selection: post_type=Companies
- Add new Filter : Choose filter the custom field: state
- In the loop output section > Put the following child view:

[wpv-view name="Child view - listing training posts"]

In Parent view, loop output section you should display all parent fields related to the company as you desired and in "Child View" you should display all required announcement fields.

Then Create a new page and add view "Parent view - listing Companies" to this page.

Please refer to the following links that may help you:
=> https://toolset.com/documentation/user-guides/passing-arguments-to-views/
=> https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/
=> https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

I hope above solution will help you to resolve your issue.

#405971

Thanks Again MInesh.. I will see how I go with this and let you know

#405972

Minesh
Supporter

Languages: English (English )

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

Yes - sure.

#406856
Screen Shot 2016-06-14 at 12.29.09 PM.png
Untitled presentation.jpg

Minesh

I tried what you suggested but don't get the result I am after.

I have successfully set up a views to filter announcements by state, however the announcements are grouped by the company that made them and those companies are listed in the date order of the posts (see first screenshot).

The view I am after now should only return the announcement post title + link for any announcements made. The view should not include company name or any other company details. It should not return anything for companies that have not made announcements.

The announcements should appear in the date order the announcements were made, not the date of the Company profile post.

I had previously set up a view for announcements which worked fine... it also included a parametric filter to enable the user to filter by announcement category.

That view returned a list of the most recent announcements made (in date order), irrespective of the company that made them AND in the date order of the announcements made This is exactly what I want to achieve, just with a state based filter added... so the output of the view produces a result as illustrated in the second screenshot... with the new filter circled in red.

How do I filter by parent field (state) and have the child posts (announcements) displayed in date order?

I would prefer not to have separate pages for the different filters. Is it possible to filter by Parent field (state) and child field (announcement category) in the same parametric search?

Cheers

Peter

#407050

Minesh
Supporter

Languages: English (English )

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

Could you please provide problem URL and view name you are using?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#407547

Minesh
Supporter

Languages: English (English )

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

Unfortunately "wp-admin" access details are not working at this end. Could you please resend it.

#407847

Minesh
Supporter

Languages: English (English )

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

Just want to confirm here: You said in first post:

to make it clear. Companies (parent CPT) make announcements (Child CPT).

So, here actually parent is "Company Profile" CPT and chid is "announcements" CPT - right?

Also, how many dropdown filter you want with view?

"Company Profile" CPT has assigned "category" - do you want to filter by category?

You want to filter by "Company Profile" parent custom field "state" and do you want to filter child posts with any filter (category or any custom field)?

could you please make this things clear to me.

#407871
Untitled presentation.jpg

Minesh

Thanks for your email

parent = company profile
child = announcement

My current need is to filter by
1. state - parent (company profile)
2. announcement category - child (announcement)

To be clear I would like 2 drop down filters as per the marked up screenshot attached which is just adding the area circled in red to my existing view for announcements which is inserted in the following page: hidden link

Thanks in anticipation.

Peter

#408010

Minesh
Supporter

Languages: English (English )

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

Ok - thank you for this information. I gone through all the structure and the thing is that as you have setup "state" field as checkboxes.

Types store checkboxes values as serialize array. For example:

a:1:{s:64:"wpcf-fields-checkboxes-option-c88e350bbe7b20818bc26141305402a0-1";s:1:"1";}

So, its not possible to add filter as we can not search on serialize array values.

First - I suggest you setup "state" as select field or as custom taxonomy.

#408040

Minesh

Thanks for your response.

We already have close to 700 entries with one or more values selected for the State Field. A select field will not work as we need the option of multi-select. A custom taxonomy might work but I have to somehow migrate the data from the current structure to a custom taxonomy. Do you know how this could be done?

If the migration is not easily done I wonder if we could implement some sort of workaround where I have a view where the filter is controlled by shortcode attributes and insert the view multiple times in a page where the viewer clicks on a hotlink for the state in question and the view loads (preferred) or are taken to a separate pages with the view inserted with different shortcode arguments for each state.

What do you think?

Peter

#408159

Minesh
Supporter

Languages: English (English )

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

You may try to export existing records and try to import it later. Please follow the following guide:
=> https://toolset.com/documentation/user-guides/how-to-import-content-into-wordpress-using-csv/

If the migration is not easily done I wonder if we could implement some sort of workaround where I have a view where the filter is controlled by shortcode attributes and insert the view multiple times in a page where the viewer clicks on a hotlink for the state in question and the view loads (preferred) or are taken to a separate pages with the view inserted with different shortcode arguments for each state.
=> this is also worth to try, it may save your time.

#411024
Screen Shot 2016-06-27 at 11.21.06 PM.png

I have had a go at trying to create a view to filter by state as I had suggested... using shortcode attribute but I can't get it to do what I wanted

What I want to achieve is the same as what I currently have in my announcements view on this page: hidden link, but with the state filter added. so the attributes of the view are as follows:

1. a list of the most recent announcements made in descending date order regardless of which company made the announcement.,

2. a drop down filter for announcement category.

I have been able to filter by state, but the announcements are grouped according to the company that made them, I also have not been able to get the announcements category filter working properly, with the filter appearing for each company rather than 1 filter for all announcements.

What I want to be able to do is set up a view controlled by shortcode attribute state= that can be inserted on the announcements page for each state that gets its own view (or each state button links to a different page where the view is inserted with a different shortcode value). See the mocked up screenshot of the main announcements page (the area circled in red is what I want to add) and I want the announcements page for each state to have an equivalent look.

I need some help getting the view right so that it produces the result described above in points 1 and 2.

I hope you can point me in the right direction.

I have another support request in to you right now and m about to provide you with login details there.

Cheers

Peter

#411175

Minesh

Was thinking about this overnight

in your response on the 16th June https://toolset.com/forums/topic/parametric-search-with-filter-by-parent-attributes/#post-408010
you said "So, its not possible to add filter as we can not search on serialize array values."

I actually got a state filter to work with a drop down but not doing quite what I was after... the filter in the Loop was as follows:

[wpv-filter-start hide="false"]
[wpv-filter-controls][wpml-string context="wpv-views"]State:[/wpml-string]
[wpv-control field="state" url_param="state" type="select" default_label="Show all" hide_empty="false"][wpv-filter-submit name="Submit" type="input"]
[/wpv-filter-controls]
[wpv-filter-end]

The filter returned accurate results based on the selection of state but the problem was results from each company were grouped together rather than displaying all announcements in chronological order.

Peter

#411333

Minesh
Supporter

Languages: English (English )

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

You can filter your posts to which view is attached.

If you want to filter your parent posts and as "State" is belongs to your parent, you can filter parent but not child as "state" is configured as checkboxes.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.